phihag / ipaddress

Python 3.3+'s ipaddress for older Python versions
Other
105 stars 53 forks source link

When comparing subnets of different versions, missing % causes the wrong exception to be raised #44

Closed yuribro closed 5 years ago

yuribro commented 6 years ago

How to reproduce:

import ipaddress
ipaddress.ip_network(u"::0/64").subnet_of(ipaddress.ip_network(u"10.0.0.0/8"))

This throws:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../.venv/local/lib/python2.7/site-packages/ipaddress.py", line 1115, in subnet_of
    return self._is_subnet_of(self, other)
  File ".../.venv/local/lib/python2.7/site-packages/ipaddress.py", line 1106, in _is_subnet_of
    raise TypeError("%s and %s are not of the same version" (a, b))
TypeError: 'unicode' object is not callable

instead of:

TypeError: ::/64 and 10.0.0.0/8 are not of the same version
yuribro commented 6 years ago

Looks like the check failed on an unrelated error in python3.2 check (an error running flake8, not in the code)

phihag commented 5 years ago

Thank you very much for the PR. I have fixed this issue (and also added a test), and will deploy a new release soon.