[Python-modules-team] Bug#460234: Bug#460234: check_addr_prefixlen exposes bug in net()/broadcast()/overlaps() methods

Bernd Zeimetz bernd at bzed.de
Sun Jan 27 01:02:41 UTC 2008

severity 460234 wishlist
retitle 460234 Support IP+prefixlen combinations like

> I didn't see http://pypi.python.org/pypi/IPy/0.55 but was looking at
> old documentation. IPy has a global option,
> IPy.check_addr_prefixlen, which, if False, allows for "uncommon"
> prefixes. Now, IP('') seems to work.

Don't use this option if you want to work with real-life address ranges.
It works, but not as you expect.

> However, now the net() and broadcast() methods return garbage:
> In [50]: IP('').net()
> Out[50]: IP('')

no, that's right, with IPy.check_addr_prefixlen == False you're creating
a /22 network which starts at Please don't use this option
if you want to handle real-life address ranges (or if you don't
understand which weirdness the option introduces....)

> In [51]: IP('').broadcast()
> Out[51]: IP('')

Still right. If we assume that the /22 network starts at,
the broadcast address is

> Also,
> IP('').overlaps('') == 0
I guess you mean 172.... there.

In [3]: IPy.IP('').overlaps('')
Out[3]: -1

Which is right for IPy.check_addr_prefixlen == False.

The function you're looking for - storing an IP with the network's
prefix length - is just not supported by IPy yet. Patches are welcome :)



Bernd Zeimetz
<bernd at bzed.de>                         <http://bzed.de/>

More information about the Python-modules-team mailing list