This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lay20114
Recipients docs@python, lay20114
Date 2022-02-03.02:46:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643856409.43.0.923620976074.issue46620@roundup.psfhosted.org>
In-reply-to
Content
ipaddress library tolerate the prefix length with leading zeros.
$ ./python.exe 
Python 3.11.0a4+ (heads/main:8fb3649450, Jan 31 2022, 16:39:46) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddress
>>> ipaddress.ip_interface('192.0.2.0/0000000024')
IPv4Interface('192.0.2.0/24')
>>> ipaddress.ip_interface('2001:db8::/0000000032')
IPv6Interface('2001:db8::/32')

The explanation of this behavior exists in follow tests.
https://github.com/python/cpython/blob/51a95be1d035a717ab29e98056b8831a98e61125/Lib/test/test_ipaddress.py#L747-L748
https://github.com/python/cpython/blob/51a95be1d035a717ab29e98056b8831a98e61125/Lib/test/test_ipaddress.py#L755-L756
https://github.com/python/cpython/blob/51a95be1d035a717ab29e98056b8831a98e61125/Lib/test/test_ipaddress.py#L592-L593

But, it seems that the explanation does not exists in the document.
https://docs.python.org/3.11/library/ipaddress.html
https://docs.python.org/3.10/library/ipaddress.html
https://docs.python.org/3.9/library/ipaddress.html
https://docs.python.org/3.8/library/ipaddress.html
https://docs.python.org/3.7/library/ipaddress.html
History
Date User Action Args
2022-02-03 02:46:49lay20114setrecipients: + lay20114, docs@python
2022-02-03 02:46:49lay20114setmessageid: <1643856409.43.0.923620976074.issue46620@roundup.psfhosted.org>
2022-02-03 02:46:49lay20114linkissue46620 messages
2022-02-03 02:46:49lay20114create