New submission from Kenta Tsuna <lay20...@gmail.com>:

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

----------
assignee: docs@python
components: Documentation
messages: 412412
nosy: docs@python, lay20114
priority: normal
severity: normal
status: open
title: Documentation of ipaddress behavior for prefix length with leading zeros.
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46620>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to