Skip to content

Compare long numeric prerelease identifiers without integer conversion - #488

Merged
tomschr merged 2 commits into
python-semver:masterfrom
SAY-5:fix-long-numeric-prerelease
Oct 1, 2026
Merged

tomschr merged 2 commits into
python-semver:masterfrom
SAY-5:fix-long-numeric-prerelease

Conversation

@SAY-5

@SAY-5 SAY-5 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #487.

A valid version with a 5,000-digit numeric prerelease parses successfully but raises ValueError when compared under Python’s default integer-conversion limit. Compare ASCII numeric prerelease identifiers by normalized digit count and text, preserving numeric-before-text ordering without converting them to integers.

The change retains constructor leading-zero comparison behavior, legacy Unicode handling and eager validation. It leaves core version parsing, release/build precedence and the optional native parser unchanged. Regression tests and a changelog fragment are included.

Validation on CPython 3.14.7 with the 4,300-digit limit unchanged:

  • Baseline: six regression failures; 80 comparison cases passed.
  • Candidate tests/: 450 passed, one optional-native-backend skip. After annotation and test-literal/formatting-only cleanup, all 86 comparison cases passed again; the algorithm and test AST were unchanged.
  • Ruff found no new lint or formatting findings against the exact baseline. Both whole-file commands remain nonzero for 74 existing diagnostics and 10 existing formatting groups.

The supported-Python tox matrix, native backend, coverage and documentation/doctest builds were not run.

OpenAI Codex assisted with the implementation, tests, independent review and this description.

@tomschr tomschr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SAY-5! I have only one suggestion (see below).

Comment thread src/semver/version.py Outdated
@tomschr
tomschr merged commit 1d51591 into python-semver:master Oct 1, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is_valid() accepts versions that compare() cannot order (int_max_str_digits)

2 participants