Repository navigation
fix(install-wheel): parse wheel version components as integers before comparison - #19479
Closed
thesayakmondal wants to merge 3 commits into
Closed
thesayakmondal wants to merge 3 commits into
thesayakmondal wants to merge 3 commits into
Conversation
Member
Is this true? Codex claims not. pip does not enforce that the version is two components, what does the spec say about that? Please don't open pull requests without test cases. |
Contributor
Author
|
You're right, I overstated the impact. This is a correctness |
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
When parsing the
WHEELmetadata file, theWheel-Versionmajor and minorcomponents were compared as raw
&strslices rather than parsed integers.The minor version check
wheel_version.1 > "0"uses lexicographic ordering,which produces incorrect results for two-digit minor versions: e.g.,
"10" > "9"is
falseas strings (since'1' < '9'), so aWheel-Version: 1.10wouldsilently skip the unsupported-minor-version warning. The major version check
wheel_version.0 != "1"has the same structural problem (e.g.,"01" != "1"is
trueas strings despite being numerically equal).This PR parses both components as
u32before comparison, matching the intentdescribed in the comment above the checks and aligning with PEP 427 semantics.
Invalid (non-numeric) version components now return
Error::InvalidWheelconsistently with other parse failures in the same function.
Test Plan
Existing tests in
test_parse_wheel_versioncontinue to pass (1.0succeeds,2.0errors). The fix can be manually verified by constructing aWHEELfilewith
Wheel-Version: 1.10and confirming the unsupported-minor-version warningis now emitted, whereas previously it was silently swallowed due to the
lexicographic comparison.