h0arry / ipaddr-py

Automatically exported from code.google.com/p/ipaddr-py
0 stars 0 forks source link

[Patch] Fix for Network equality #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Based on the current consensus Networks that define the same .network and 
.netmask should test equal ==, and the repr and str representations should 
be the same and not contain the IP use to generate the Network

I have done up a patch http://codereview.appspot.com/124057 such that

>>> IPv4Network(192.168.1.1/24)
IPv4Network(192.168.1.0/24)

>>> x = IPv4Network('192.168.1.1/24')
>>> y = IPv4Network('192.168.1.0/24')
>>> x == y
True
>>> hash(x) == hash(y)
True

The ip you instantiated the Network with is still accessible though, so
>>> x.ip
IPv4Address('192.168.1.1')
>>> y.ip
IPv4Address('192.168.1.0')

Original issue reported on code.google.com by digitalx...@gmail.com on 30 Sep 2009 at 3:31

GoogleCodeExporter commented 9 years ago
fixed in r118

>>> ipaddr.IPNetwork('1.1.1.1/25') == ipaddr.IPNetwork('1.1.1.10/25')
True
>>> ipaddr.IPNetwork('1.1.1.1/25') < ipaddr.IPNetwork('1.1.1.10/25')
False
>>> ipaddr.IPNetwork('1.1.1.1/25') <= ipaddr.IPNetwork('1.1.1.10/25')
True

Original comment by pmo...@google.com on 10 Oct 2009 at 8:30