The issue is in the underlying ipranges
library.
When searching for network in the networks module, the input is converted to IP object from ipranges so that it would be possible to search for supersets. The change was introduced in dd0502fd (I am really glad I put those comments there ).
Anyway, the following code in ipranges
:
def ip_from_str(s):
for t in IP4, IP6:
try:
return t(s)
except ValueError:
pass
raise ValueError("%s does not appear as IPv4 nor IPv6 address" % s)
tries to convert first to IPv4 address, but this produces the following type of error for IPv6 addresses:
>>> ipranges.ip_from_str(42540632040320178)
Traceback (most recent call last):
File "/var/mentat/venv/lib/python3.7/site-packages/ipranges.py", line 188, in ip4_to_str
return socket.inet_ntop(socket.AF_INET, struct.pack('!L', i))
struct.error: 'L' format requires 0 <= number <= 4294967295
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/mentat/venv/lib/python3.7/site-packages/ipranges.py", line 55, in __repr__
return "%s('%s')" % (type(self).__name__, str(self))
File "/var/mentat/venv/lib/python3.7/site-packages/ipranges.py", line 169, in __str__
def __str__(self): return self.to_str(self.ip)
File "/var/mentat/venv/lib/python3.7/site-packages/ipranges.py", line 190, in ip4_to_str
raise ValueError("Unable to convert to IPv6 address: %s" % i)
ValueError: Unable to convert to IPv6 address: 42540632040320178