[Distutils] multiple backports of ipaddress and a world of pain
phihag at phihag.de
Tue Feb 16 17:31:22 EST 2016
Code that uses py2-ipaddress will break upon migrating to Python 3, and
potentially in really subtle ways. For instance,
import py2_ipaddress as ipaddress
has different semantics in Python 2 and Python 3. Also note that if you
actually want to generate an ipaddress object from a binary
representation, py2-ipaddress' "solution"
will break as well under Python 3, but at least it will throw an
exception and not silently do something different.
Therefore, code that uses py2-ipaddress needs to be fixed anyways in
order to work correctly under Python 3 - might as well do it now.
py2-ipaddress' API is incompatible with the ipaddress from the stdlib,
so I don't think it should claim the module name ipaddress in the first
place. Why one would actively introduce incompatibilities between Python
2 and Python 3 *after Python 3 has long been released* is beyond my
Specifically for django-netfields, a workaround is to always use
character strings (unicode type in Python 2, str in Python 3).
Greetings from Düsseldorf,
On 16.02.2016 19:37, Chris Withers wrote:
> Hi All,
> (Apologies for copying in the maintainers of the two backports and
> django-netfields directly, I'm not sure you're on this distutils list...)
> This is painful and horrible, and I wish pip would prevent
> modules/packages with the same name being installed by different
> distributions at the same time, but even if it did, that would just
> force something to happen rather than this:
> So, RHEL7, for worse or worse, ships with Python 2.7.5. That means to
> keep pip happy, you need to do these dances in all the virtualenvs you
> One of those extra packages drags in this backport:
> Yay! Now we have a happy pip talking to both PyPI and our internal DevPI
> Right, so in a Django project I need to use
> https://pypi.python.org/pypi/django-netfields. This, however, chooses
> this backport instead:
> So, now we have two packages installing ipaddress.py, except they're two
> very different versions and make different assumptions about what to do
> with Python 2 strings.
> What should happen here? (other than me crying a lot...)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the Distutils-SIG