timothycrosley / deprecated.pies

The simplest (and tastiest) way to write one program that runs on both Python 2 and Python 3.
MIT License
148 stars 7 forks source link

Breaks third-party modules #49

Open shazow opened 9 years ago

shazow commented 9 years ago

Hi there, turns out that there are a lot of Python libraries out there who already do their own Python 2/3 compatibility. Usually it looks like:

try:
    from python3versionofthelib import foo as Quux
except ImportError:
    from python2versionofthelib import bar as Quux

When somebody is using pies, it can make other libraries that know nothing about pies not work. urllib3 and libraries that depend on it is one such example: https://github.com/elastic/elasticsearch-py/issues/253

This is largely because pies does a from ... import * in the shim.

Personally I'm not sure that modifying the global python namespace that other libraries might be depending on is a good idea, so I'd recommend against this approach. But at the very least, please consider doing it a different way such that it doesn't break other libraries.

sigmavirus24 commented 9 years ago

Or make sure you're actually importing the correct symbols for the namespace. Clearly import * is not sufficient

timothycrosley commented 9 years ago

pies is on it's way to be deprecated by pie slice, as included by isort in the most recent release - which is a single file solution and completely avoids these issues. I agree that as it stands master pies does not work well with certain projects, however little can be done about it since it's inherit with how pies works and the entire concept around the initial implementation

shazow commented 9 years ago

How about at least a warning on the readme/pypi listing that usage of pies is known got break other libraries?

timothycrosley commented 9 years ago

@shazow, hope to release its successor sometime this week, when that happens I'll add a deprecation note, warning, and redirection link. Till then I'll go ahead and reopen this issue.

Thanks everyone!

~Timothy

mcfletch commented 9 years ago

Hmm, somehow I wound up with pies installed (likely via a dependency statement from some piece of software). Which then broke my requests (urllib3) code. I'm not sure why "six" is importing from pies' http module, but it does on my Python 2.7.8 venvs, which then breaks urllib3. The missing import is HTTPMessage, BTW.

If the package is left up on PyPI it should likely be fixed at least to avoid breaking something as ubiquitous as requests/urllib3, which breaks code in subtle and fun ways.

sigmavirus24 commented 9 years ago

@mcfletch six doesn't intentionally import it from pies. Pies places a module in site-packages which shadows the standard library causing all kinds of awful horrors. This was found to be a problem with a couple of non-six compatibility libraries in https://github.com/elastic/elasticsearch-py/issues/253. Six just works because it's explicit and doesn't try to do magic to your python environment.

This should also be fixed in newer versions of urllib3 and requests. If it isn't, please post the traceback and version information so we can further guard against this.