Repository navigation
Return all 64 bits of the version from getversion() - #1607
Merged
Merged
Conversation
getversion() built its result with PyLong_FromUnsignedLong(), and unsigned long is 32 bits on Windows and on 32-bit platforms, so the uint64_t version was truncated there and two different versions could compare equal. MultiDict_GetVersion() in the C API was not affected. Add a test-only _setversion() hook so a test can put a version above 2**32 without making 2**32 mutations.
asvetlov
marked this pull request as ready for review
September 26, 2026 20:16
Contributor
|
This comment has been minimized.
This comment has been minimized.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1607 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 43 43
Lines 7978 7986 +8
Branches 669 669
=========================================
+ Hits 7978 7986 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
# Conflicts: # tests/test_version.py
…n-64bit # Conflicts: # tests/test_version.py
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.
What do these changes do?
getversion()built its result withPyLong_FromUnsignedLong().unsigned longis 32 bits on every Windows build, 64-bit included, and on 32-bit platforms, so theuint64_tversion came back truncated to its low 32 bits there. It now usesPyLong_FromUnsignedLongLong().A test-only
_setversion()hook, next to_freelist_clear(), lets the test set a version above 232 without making 232 mutations.Are there changes in behavior for the user?
Yes, on Windows and 32-bit platforms:
getversion()returns the full 64-bit version. Before, two different versions that shared their low 32 bits compared equal. That took about 4.3e9 mutations with the current global counter, but only about 16.7 million new multidicts once #1605 lands, since each multidict then takes a block of 256 versions.MultiDict_GetVersion()in the C API already returned the fulluint64_tand is unchanged. The pure-Python implementation is not affected.Is it a substantial burden for the maintainers to support this?
No. It is a one-call fix plus a test hook.
Related issue number
Found while reviewing #1605.
Checklist
CONTRIBUTORS.txt(N/A, existing contributor)CHANGES/foldermake doc-spellingpasses and any new technical words are added todocs/spelling_wordlist.txtDrafted with Claude Code (Claude Opus 5.5); reviewed by @asvetlov.
Agent run details (optional, for reviewers)
On Linux x86-64
unsigned longis 64 bits, so the bug does not show locally; the Windows CI jobs exercise it for real. To check that the test catches truncation, it was run against a build that simulates a 32-bitunsigned longwithPyLong_FromUnsignedLong((uint32_t)load_version(md)): both parametrized cases fail there and pass with the fix.Tests:
pytestpasses on 3.14.7, 3.14.7t, 3.10.17 and pure Python (3.13.2), each in its own tree copy and venv. The new test is skipped on the pure-Python leg throughpytest.importorskip("multidict._multidict").make doc-spelling: passes.