Closed GoogleCodeExporter closed 9 years ago
interesting, I'll check this out.
Original comment by pmo...@google.com
on 27 Aug 2009 at 9:26
Attempting to reproduce this in r176 I see the following:
subnet = IPNetwork('192.0.2.0/30')
networks = [subnet]
networks.extend(list(subnet))
Note at this point we now have mixed types:
print networks
=> [IPv4Network('192.0.2.0/30'), IPv4Address('192.0.2.0'),
IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'), IPv4Address('192.0.2.3')]
# With a mix of Addresses and Networks the comparison fails with traceback -
which is correct behavior.
networks[0] > networks[1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/harro/Source/ipaddr-py/trunk/ipaddr.py", line 556, in __gt__
str(self), str(other)))
TypeError: 192.0.2.0/30 and 192.0.2.0 are not of the same type
To confirm that the sort is actually OK with same type. Lets cast the IP
addresses into /32 Networks and compare after randomising:
realnets = []
for x in networks:
realnets.append(IPNetwork(x))
random.shuffle(realnets)
for subnet in sorted(realnets):
print subnet
=>
192.0.2.0/28
192.0.2.0/29
192.0.2.0/30
192.0.2.0/31
192.0.2.0/32
192.0.2.1/32
192.0.2.2/31
192.0.2.2/32
192.0.2.3/32
192.0.2.4/30
192.0.2.4/31
192.0.2.4/32
192.0.2.5/32
192.0.2.6/31
192.0.2.6/32
192.0.2.7/32
192.0.2.8/29
192.0.2.8/30
192.0.2.8/31
192.0.2.8/32
192.0.2.9/32
192.0.2.10/31
192.0.2.10/32
192.0.2.11/32
192.0.2.12/30
192.0.2.12/31
192.0.2.12/32
192.0.2.13/32
192.0.2.14/31
192.0.2.14/32
192.0.2.15/32
So looks like this issue can be closed.
Original comment by ha...@google.com
on 20 Jul 2010 at 3:30
Original comment by ha...@google.com
on 20 Jul 2010 at 3:32
Original issue reported on code.google.com by
drk...@gmail.com
on 27 Aug 2009 at 9:13