-
Notifications
You must be signed in to change notification settings - Fork 175
Closed
Description
I am in the process of upgrading netaddr from 0.10.1 to 1.2.1, my Python version is 3.12.3.
In older versions the netaddr.ZEROFILL flag was ignored when a IPv6 address was given:
# netaddr==0.10.1
>>> import netaddr
>>> ip = netaddr.IPAddress('2600:1f18:631e:2f85:93a9:f7b0:d18:89a7', flags=netaddr.ZEROFILL)
>>> ip
IPAddress('2600:1f18:631e:2f85:93a9:f7b0:d18:89a7')In the current release it throws an ValueError:
# netaddr==1.2.1
>>> import netaddr
>>> ip = netaddr.IPAddress('2600:1f18:631e:2f85:93a9:f7b0:d18:89a7', flags=netaddr.ZEROFILL)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/lib/python3.12/site-packages/netaddr/ip/__init__.py", line 333, in __init__
self._value = module.str_to_int(addr, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/netaddr/strategy/ipv4.py", line 120, in str_to_int
addr = '.'.join(['%d' % int(i) for i in addr.split('.')])
^^^^^^
ValueError: invalid literal for int() with base 10: '2600:1f18:631e:2f85:93a9:f7b0:d18:89a7'Suggestion: ignore the netaddr.ZEROFILL flag when a IPv6 is given.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels