autocracy / python-ipy

IPy are a Python class and tools for handling of IPv4 and IPv6 addresses and networks. It is similar to Net::IP Perl module.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

version testing on /31(and /127) network fails

paddy01 opened this issue · comments

When doing .version() on a /31 or a /127 network the test throws an error with the "upper" ip.

Examples:
IP("198.51.100.3/31").version() <-- fails
IP("198.51.100.2/31").version() <-- works as expected
IP("2001:db8:2::1/127").version() <-- fails
IP("2001:db8:2::0/127").version() <-- works as expected

This can be worked around with make_net=True
IP("198.51.100.3/31", make_net=True).version() <-- now works as expected
IP("2001:db8:2::1/127", make_net=True).version() <-- now works as expected

Using make_net seems right. 198.51.100.3/31 is an invalid individual network address, and network masks are typically specified only with the network address. Note that it fails even without .version(); the exception is earlier.

I consider this intended behavior.