summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJoel Croteau <jcroteau@gmail.com>2019-03-30 14:53:48 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2019-03-30 14:53:48 (GMT)
commite653d4d8e820a7a004ad399530af0135b45db27a (patch)
tree140ff14e2dccd2daf4a7e7b28a6db743f6347c6d /Lib/test
parentddbb978e1065dde21d1662386b26ded359f4b16e (diff)
downloadcpython-e653d4d8e820a7a004ad399530af0135b45db27a.zip
cpython-e653d4d8e820a7a004ad399530af0135b45db27a.tar.gz
cpython-e653d4d8e820a7a004ad399530af0135b45db27a.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ipaddress.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
index 0e0753f..53f6f12 100644
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -92,11 +92,14 @@ class CommonTestMixin:
y = pickle.loads(pickle.dumps(x, proto))
self.assertEqual(y, x)
+
class CommonTestMixin_v4(CommonTestMixin):
def test_leading_zeros(self):
self.assertInstancesEqual("000.000.000.000", "0.0.0.0")
self.assertInstancesEqual("192.168.000.001", "192.168.0.1")
+ self.assertInstancesEqual("016.016.016.016", "16.16.16.16")
+ self.assertInstancesEqual("001.000.008.016", "1.0.8.16")
def test_int(self):
self.assertInstancesEqual(0, "0.0.0.0")
@@ -229,15 +232,6 @@ class AddressTestCase_v4(BaseTestCase, CommonTestMixin_v4):
assertBadOctet("1.2.3.4::", "4::")
assertBadOctet("1.a.2.3", "a")
- def test_octal_decimal_ambiguity(self):
- def assertBadOctet(addr, octet):
- msg = "Ambiguous (octal/decimal) value in %r not permitted in %r"
- with self.assertAddressError(re.escape(msg % (octet, addr))):
- ipaddress.IPv4Address(addr)
-
- assertBadOctet("016.016.016.016", "016")
- assertBadOctet("001.000.008.016", "008")
-
def test_octet_length(self):
def assertBadOctet(addr, octet):
msg = "At most 3 characters permitted in %r in %r"