Repository navigation
Conversation
r266-tech
force-pushed
the
codex/version-raw-version
branch
from
October 9, 2026 10:18
0113517 to
cab6070
Compare
Wkhanex
reviewed
Oct 14, 2026
Wkhanex
left a comment
There was a problem hiding this comment.
The raw accessor retains the exact input spelling, including whitespace, leading v, capitalization and local-version text. Pickle protocols 2–5 preserve that string without changing equality/hash; versions built from parts, replaced versions and legacy six-field states return None for raw input.
Checked cab6070464d8 with standalone Python 3.12.14 checks (49 passing assertions). I haven't run the full upstream suite.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a read-only
Version.raw_versionproperty that preserves the exact input string used by the constructor. Versions built withfrom_parts, changed with__replace__, or restored from older pickles returnNone; unchanged replacements preserve the original value. Comparison and hashing remain based only on normalized PEP 440 fields.New pickles include the raw input, while
__setstate__continues to accept the existing six-field and older pickle formats.Fixes #1418.
Validation
uv run --no-sync pytest -q tests/test_version.py— 51,525 passed.ruff check src/packaging/version.py tests/test_version.py— passed.ruff format --check src/packaging/version.py tests/test_version.py— passed.git diff --check— passed.