bpo-35989: Forbid a netmask > 32 for ipaddress.IPv4Network by matrixise · Pull Request #11844 · python/cpython
➜ cpython git:(master) ./python
Python 3.10.0a0 (heads/master:07d8112812, Jun 10 2020, 23:50:22)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddress
>>> ipaddress.IPv4Network(('192.0.2.1', 33))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/remi/src/cpython/Lib/ipaddress.py", line 1500, in __init__
self.netmask, self._prefixlen = self._make_netmask(mask)
File "/Users/remi/src/cpython/Lib/ipaddress.py", line 1162, in _make_netmask
cls._report_invalid_netmask(prefixlen)
File "/Users/remi/src/cpython/Lib/ipaddress.py", line 474, in _report_invalid_netmask
raise NetmaskValueError(msg) from None
ipaddress.NetmaskValueError: 33 is not a valid netmask