summaryrefslogtreecommitdiffstats
path: root/Doc/library/ipaddress.rst
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-02 13:49:03 (GMT)
committerGitHub <noreply@github.com>2021-05-02 13:49:03 (GMT)
commit5374fbc31446364bf5f12e5ab88c5493c35eaf04 (patch)
treedf1f73273aafe1a0e0da4358cb15da64c66bf71c /Doc/library/ipaddress.rst
parentcf6a79644c227159b8b5a44055650266d578b9f6 (diff)
downloadcpython-5374fbc31446364bf5f12e5ab88c5493c35eaf04.zip
cpython-5374fbc31446364bf5f12e5ab88c5493c35eaf04.tar.gz
cpython-5374fbc31446364bf5f12e5ab88c5493c35eaf04.tar.bz2
bpo-36384: Leading zeros in IPv4 addresses are no longer tolerated (GH-25099) (GH-25815)
Reverts commit e653d4d8e820a7a004ad399530af0135b45db27a and makes parsing even more strict. Like socket.inet_pton() any leading zero is now treated as invalid input. Signed-off-by: Christian Heimes <christian@python.org> Co-authored-by: Ɓukasz Langa <lukasz@langa.pl> (cherry picked from commit 60ce8f0be6354ad565393ab449d8de5d713f35bc)
Diffstat (limited to 'Doc/library/ipaddress.rst')
-rw-r--r--Doc/library/ipaddress.rst19
1 files changed, 17 insertions, 2 deletions
diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst
index d6d1f1e..1c2263b 100644
--- a/Doc/library/ipaddress.rst
+++ b/Doc/library/ipaddress.rst
@@ -104,8 +104,7 @@ write code that handles both IP versions correctly. Address objects are
1. A string in decimal-dot notation, consisting of four decimal integers in
the inclusive range 0--255, separated by dots (e.g. ``192.168.0.1``). Each
integer represents an octet (byte) in the address. Leading zeroes are
- tolerated only for values less than 8 (as there is no ambiguity
- between the decimal and octal interpretations of such strings).
+ not tolerated to prevent confusion with octal notation.
2. An integer that fits into 32 bits.
3. An integer packed into a :class:`bytes` object of length 4 (most
significant octet first).
@@ -117,6 +116,22 @@ write code that handles both IP versions correctly. Address objects are
>>> ipaddress.IPv4Address(b'\xC0\xA8\x00\x01')
IPv4Address('192.168.0.1')
+ .. versionchanged:: 3.8
+
+ Leading zeros are tolerated, even in ambiguous cases that look like
+ octal notation.
+
+ .. versionchanged:: 3.10
+
+ Leading zeros are no longer tolerated and are treated as an error.
+ IPv4 address strings are now parsed as strict as glibc
+ :func:`~socket.inet_pton`.
+
+ .. versionchanged:: 3.9.5
+
+ The above change was also included in Python 3.9 starting with
+ version 3.9.5.
+
.. attribute:: version
The appropriate version number: ``4`` for IPv4, ``6`` for IPv6.