You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Presence of otherwise absence modules breaks conditional imports #158
As CherryPy was a pioneer in supporting Python 3 on a non-trivial library (and the first web framework), it has had this compatibility library since before six and future were mature.
However, the presence of future breaks this library. If an application pulls in future on Python 2, the CherryPy detection for urllib.parse will erroneously select the Python 3 invocation, but on Python 2, even with future installed, the unquote function does not accept the encoding parameter and will fail with a TypeError when invoked. This behavior has recently worked its way into one of our applications and is causing the test suite to fail. If it works into production, it could cause our apps to fail.
I see several possible ways to address the issue:
python-future accepts this as a bug (exposing a Python 3 function without the full Python 3 interface) and corrects it, such that even if CherryPy selects that implementation, it will work on Python 2 as on Python 3.
We scour the dependencies and exclude any that are pulling python-future into the application. This technique would pin our application to old code, prevent forward compatibility, and exclude the possibility of using python-future.
Users submit bug reports to each and every library that uses conditional imports for feature detection, including CherryPy, patch those libraries, re-release them, and update the applications that depend on them. This approach would be tedious and drawn out and would prevent use of older versions of these libraries.
There are probably others as well.
I'd like to get a read from the python-future maintainers. Is this a known issue with the technique (I didn't see any bugs reporting something similar)? What do you recommend be done?
After tracking the library that was triggering this behavior, I found it was invoking this:
from future import standard_library
standard_library.install_aliases()
I suspect that call is implicated, and while it's an optional invocation, it came as the result of running futurize on the codebase, so would be likely to be called by other libraries employing the use of future.
Activity
jaraco commentedon Jul 23, 2015
After tracking the library that was triggering this behavior, I found it was invoking this:
I suspect that call is implicated, and while it's an optional invocation, it came as the result of running
futurizeon the codebase, so would be likely to be called by other libraries employing the use offuture.edschofield commentedon Jul 24, 2015
Jason, thanks very much for highlighting this. I'm going to choose (1): to accept this as a bug. I'm working on a fix now.
Add test that highlights issue #158
install_aliases(): expose the full backported urllib modules instead …
edschofield commentedon Jul 25, 2015
I've released a new version (v0.15.0) that should resolve this bug. Please let me know if it works for you!
jaraco commentedon Jul 25, 2015
What service! Thank you.