`IPv6Network.next_network()` raises the wrong error when addresses run out
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug description:
_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 versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-156681
- gh-157280
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review _BaseNetwork.next_network() and the next_network() wording in Doc/library/ipaddress.rst, then reproduce the IPv4 and IPv6 examples from the issue. Done means IPv6 address-space exhaustion reports the documented “out of address space” message for the /112 network instead of “IPv6 address is too large”.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100