python3-netaddr 0.7.10 with poor python3 support

Bug #1307733 reported by Sören Berger
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-netaddr (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

Ubuntu 14.04 (beta2) currently ships with python3-netaddr 0.7.10:

$ lsb_release -rd
Description: Ubuntu 14.04 LTS
Release: 14.04

$ apt-cache policy python3-netaddr
python3-netaddr:
  Installed: 0.7.10-1build1
  Candidate: 0.7.10-1build1
  Version table:
 *** 0.7.10-1build1 0
        500 http://de.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

This release is over 18 months old. In the current release there are a lot of bugfixes. During my development I got some nasty errors which are fixed in the current relese 0.7.11. See [1].

Especially the bug about the len() in IPSet makes the library not really useful in python3.

$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from netaddr import IPSet
>>> len(IPSet(["192.168.0.0/24"]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/netaddr/ip/sets.py", line 518, in __len__
    if size > _sys.maxint:
AttributeError: 'module' object has no attribute 'maxint'
>>>

This is because in python3 sys.maxint not exists and is replaced by sys.maxsize

It seems this version was not completely ported to python3. This bug[2] (and others) are fixed in the current stable version 0.7.11

I would suggest to give this library a version bumb to 0.7.11.

If I can support you somehow, let it me know.

[1] http://pythonhosted.org//netaddr/changes.html
[2] https://github.com/drkjam/netaddr/issues/46

Revision history for this message
James Page (james-page) wrote :

later release have the newer version, however trusty still has 0.7.10 - are there any specific bugs we should cherry pick for the py3 support? it might be better to resolve specific bug users experience.

Changed in python-netaddr (Ubuntu):
status: New → Incomplete
Revision history for this message
Sören (soerensensen) wrote :

I went through the changes and if a bump to 0.7.11 (or higher) is not possible I would cherry pick:

https://github.com/drkjam/netaddr/issues/46 (my Issue and python3 specific)

Bugs I would fix in python-netaddr and python3-netaddr:

https://github.com/drkjam/netaddr/issues/38 (accidently removed function)
https://github.com/drkjam/netaddr/issues/53 (Allign implementation to RFC spec)
https://github.com/drkjam/netaddr/issues/56 (Fix IPv6 compare function)

Revision history for this message
Adam Stokes (adam-stokes) wrote :

James,

I looked into using this module in our cloud installer, one bug in particular that exists in 0.7.10 but not in 0.7.13 is the use of sys.maxint:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/share/openstack/cloudinstall/netutils.py", line 78, in get_ip_set
    ips = list(IPSet([cidr]))
  File "/usr/lib/python3/dist-packages/netaddr/ip/sets.py", line 518, in __len__
    if size > _sys.maxint:
AttributeError: 'module' object has no attribute 'maxint'

Code to reproduce:
from netaddr import IPSet
def get_ip_set(cidr):
    """ Returns a list of ip's in cidr for use in juju's no-proxy setting
    """
    ips = list(IPSet([cidr]))
    return ",".join(str(x) for x in ips)

get_ip_set('10.0.4.0/24')

Revision history for this message
Adam Stokes (adam-stokes) wrote :

Looks like a small typo

if size > _sys.maxint should be if size > _sys_maxint

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for python-netaddr (Ubuntu) because there has been no activity for 60 days.]

Changed in python-netaddr (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.