Hi Peter. Looks like _count_righthand_zero_bits is only called from
one place in the module, and from that context, it may not ever tickle
that bug, I'm not sure. I was actually calling it directly from my own
code in which I wanted to check whether a prefix had any extra bits
set (beyond the prefix length). For example:
is well-formed in that all bits after the first 16 are zeroes.
does have a bit set beyond the prefix length
A lot of prefix parsers (ipaddr.py code included) tolerate extra bits
set in this fashion. However, I needed to catch prefixes with extra
bits set, so I was taking the integer form of a prefix and checking
whether the number of righthand zero bits was less than or equal to 32
minus the prefix length.
For example, for IPAddress object p, this code performs that check:
if (_count_righthand_zero_bits(p._ip, p._max_prefixlen-p._prefixlen) <
# do something
Hope that helps clarify,