_BaseNetwork.next_network() guards address-space exhaustion with except OverflowError, which only the IPv4 path raises, so on IPv6 the internal ValueError from _string_from_ip_int() escapes instead.
from ipaddress import IPv4Network, IPv6Network for net in (IPv4Network('255.255.255.0/24'), IPv6Network('ffff:ffff:ffff:ffff:ffff:ffff:ffff:0/112')): try: net.next_network() except ValueError as e: print(f"{net}: {e}")
Output:
255.255.255.0/24: out of address space, cannot make another /24 network ffff:ffff:ffff:ffff:ffff:ffff:ffff:0/112: IPv6 address is too large
Expected: out of address space, cannot make another /112 network, the message Doc/library/ipaddress.rst gives for next_network().
CPython main branch
Linux
Hopefully should be resolved under c6b1d1a
gh-156680: Raise the documented error from IPv6Network.next_network() (…
Reopening this to update a doc string of the module.
pythongh-156680 - Update IPv4Network and IPv6Network docstring.
pythongh-156680: Raise the documented error from IPv6Network.next_net…
gh-156680 - Update IPv4Network and IPv6Network docstring. (#157280)
Activity
777GE90 commented on Aug 30, 2026
Hopefully should be resolved under c6b1d1a
gh-156680: Raise the documented error from IPv6Network.next_network() (…
orsenthil commented on Sep 10, 2026
Reopening this to update a doc string of the module.
pythongh-156680 - Update IPv4Network and IPv6Network docstring.
pythongh-156680: Raise the documented error from IPv6Network.next_net…
pythongh-156680: Raise the documented error from IPv6Network.next_net…
gh-156680 - Update IPv4Network and IPv6Network docstring. (#157280)