mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-36384: Remove check for leading zeroes in IPv4 addresses (GH-12577)
Stop rejecting IPv4 octets with leading zeroes as ambiguously octal. Plenty of other tools generate decimal IPv4 octets with leading zeroes, so keeping this check hurts interoperability. Patch by Joel Croteau.
This commit is contained in:
parent
ddbb978e10
commit
e653d4d8e8
3 changed files with 4 additions and 15 deletions
|
@ -1165,12 +1165,6 @@ class _BaseV4:
|
|||
raise ValueError(msg % octet_str)
|
||||
# Convert to integer (we know digits are legal)
|
||||
octet_int = int(octet_str, 10)
|
||||
# Any octets that look like they *might* be written in octal,
|
||||
# and which don't look exactly the same in both octal and
|
||||
# decimal are rejected as ambiguous
|
||||
if octet_int > 7 and octet_str[0] == '0':
|
||||
msg = "Ambiguous (octal/decimal) value in %r not permitted"
|
||||
raise ValueError(msg % octet_str)
|
||||
if octet_int > 255:
|
||||
raise ValueError("Octet %d (> 255) not permitted" % octet_int)
|
||||
return octet_int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue