Bug report
Bug description:
Documented behaviour: Python ipaddress documentation, IPv4Network.supernet: "A ValueError is raised if new_prefix is larger than our prefix."
Expected: supernet(new_prefix=1) raises ValueError for IPv4Network('0.0.0.0/0').
Actual: Returns IPv4Network('0.0.0.0/0') without raising an exception.
import ipaddress
network, p = "0.0.0.0/0", 1
n = ipaddress.IPv4Network(network)
if not isinstance(p, int) or not 0 <= p <= 32:
print("REFUTATION REJECTED: invalid IPv4 prefix")
else:
expected = ("exception", "ValueError") if p > n.prefixlen else (
"result", str(ipaddress.IPv4Network((int(n.network_address), p), strict=False))
)
try:
actual = ("result", str(n.supernet(new_prefix=p)))
except Exception as e:
actual = ("exception", type(e).__name__)
if actual != expected:
print("REFUTATION CONFIRMED:", {"network": network, "new_prefix": p},
"actual=", actual, "expected=", expected)
else:
print("REFUTATION REJECTED: actual matches documented expectation")
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library ipaddress:
REFUTATION CONFIRMED: {'network': '0.0.0.0/0', 'new_prefix': 1} actual= ('result', '0.0.0.0/0') expected= ('exception', 'ValueError')
This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/ipaddress-c4
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: Python ipaddress documentation, IPv4Network.supernet: "A ValueError is raised if new_prefix is larger than our prefix."
Expected: supernet(new_prefix=1) raises ValueError for IPv4Network('0.0.0.0/0').
Actual: Returns IPv4Network('0.0.0.0/0') without raising an exception.
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library
ipaddress:This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/ipaddress-c4
CPython versions tested on:
3.14
Operating systems tested on:
Windows