P2Exception behaviour changed
known regression: unicode-digitsknown regression: inner-whitespace
inputVersion("0")
baseraises InvalidVersion
headreturns normally
Likely bugvotes: 3 likely-bug
The fast‑path treats any character not in `_NON_SIMPLE_VERSION_INDICATORS` as a simple numeric version. The set deliberately lists ASCII letters and punctuation (e.g. `!+-ABCDEHILOPRSTVW_abcdehiloprstvw`) but does not include full‑width digits such as `0`. Consequently `Version('0')` is accepted by the fast‑path (`int('0')` succeeds) whereas the original regex rejects it, a non‑conformant change.
_NON_SIMPLE_VERSION_INDICATORS = frozenset('!+-ABCDEHILOPRSTVW_abcdehiloprstvw')
if _NON_SIMPLE_VERSION_INDICATORS.isdisjoint(version):
Found by: Nemotron strategy search, Ultra's planned example, hostile mutation, search sample · also caught by: Nemotron plan only
ran onlocal Docker · image bw-pair:348e2d05c100a5f9
Regression test verified passes on base, fails on head
def test_1082_61967cca_p2_outcome_0():
"""Breakwater P2: base behaviour pinned (found by differential testing; label: likely-bug)."""
import pytest
from packaging.version import InvalidVersion, Version
with pytest.raises(InvalidVersion) as excinfo:
Version('0')
assert type(excinfo.value) is InvalidVersion # exact type: a subclass would be a behaviour change
Reproduce
uv run breakwater probe --repo https://github.com/pypa/packaging --base 59f183fe90da --head 61967cca278d --target packaging.version:Version --backend docker --input "0"
1 near-duplicate class same behaviour, inputs with extra traits
Version("0 ") base raises InvalidVersion · head returns normallyunicode-digitsinner-whitespace test verified (also under another group)
P2Exception behaviour changed
known regression: inner-whitespaceknown regression: unicode-digits
inputVersion(" 1. 2.3 ")
baseraises InvalidVersion
headreturns normally
Likely bugvotes: 3 likely-bug
The fast‑path calls `version.strip()` before splitting on dots, thereby accepting leading/trailing whitespace (e.g. `' 1.2.3 '`). PEP 440 does not permit whitespace in a version string, and the original regex rejects it. The change was not mentioned in the PR description, indicating an unintended relaxation.
if _NON_SIMPLE_VERSION_INDICATORS.isdisjoint(version):
self._release = tuple(map(int, version.strip().split('.')))
Found by: hostile mutation · also caught by: Mutations of the PR's own test strings
ran onlocal Docker · image bw-pair:348e2d05c100a5f9
Regression test verified passes on base, fails on head
def test_1082_61967cca_p2_outcome_4():
"""Breakwater P2: base behaviour pinned (found by differential testing; label: likely-bug)."""
import pytest
from packaging.version import InvalidVersion, Version
with pytest.raises(InvalidVersion) as excinfo:
Version(' 1. 2.3 ')
assert type(excinfo.value) is InvalidVersion # exact type: a subclass would be a behaviour change
Reproduce
uv run breakwater probe --repo https://github.com/pypa/packaging --base 59f183fe90da --head 61967cca278d --target packaging.version:Version --backend docker --input " 1. 2.3 "
1 near-duplicate class same behaviour, inputs with extra traits
Version("0 ") base raises InvalidVersion · head returns normallyunicode-digitsinner-whitespace test verified (also under another group)
P2Exception behaviour changed
known regression: inner-whitespaceknown regression: oversized-int-exception
inputVersion(" 10000000000000000000000000000000000000000…000000000 " (4,303 chars))
baseraises ValueError
headraises InvalidVersion
Packaging.version.InvalidVersion is a subclass of builtins.ValueError.
Intendedvotes: 2 intended, 1 needs-human
The fast‑path explicitly converts a `ValueError` from the integer parsing into `InvalidVersion` (`except ValueError: raise InvalidVersion(...)`). When the fast‑path is taken and the integer conversion fails, the new code raises `InvalidVersion` instead of letting the original `ValueError` propagate, which matches the observed change.
self._release = tuple(map(int, version.strip().split('.')))
except ValueError: raise InvalidVersion(f'Invalid version: {version!r}') from None
Found by: hostile mutation · no baseline found it
ran onlocal Docker · image bw-pair:348e2d05c100a5f9
No regression test: adjudicated intended: no test pins the old behaviour.
P2Exception behaviour changed
known regression: unicode-digitsknown regression: oversized-int-exception
inputVersion("100000000000000000000000000000000000000000…000000.2.3" (4,304 chars))
baseraises InvalidVersion
headreturns normally
Intendedvotes: 2 intended, 1 needs-human
The fast‑path is designed to accept simple dot‑separated numeric versions without invoking the full regex. A very long all‑digit version passes the `_NON_SIMPLE_VERSION_INDICATORS.isdisjoint` test and is parsed successfully, whereas the original regex path rejects it (raising `InvalidVersion`). This is the performance optimisation the PR targets.
_NON_SIMPLE_VERSION_INDICATORS = frozenset('!+-ABCDEHILOPRSTVW_abcdehiloprstvw')
if _NON_SIMPLE_VERSION_INDICATORS.isdisjoint(version):
Found by: hostile mutation · no baseline found it
ran onlocal Docker · image bw-pair:348e2d05c100a5f9
No regression test: adjudicated intended: no test pins the old behaviour.