Title: Fix 32-bit random bit counts and hash compatibility by youknowone · Pull Request #9437 · RustPython/RustPython · GitHub
Open Graph Title: Fix 32-bit random bit counts and hash compatibility by youknowone · Pull Request #9437 · RustPython/RustPython
X Title: Fix 32-bit random bit counts and hash compatibility by youknowone · Pull Request #9437 · RustPython/RustPython
Description: Summary Fix three reproducible Windows x86 compatibility failures without modifying Lib/ or existing test assertions: Accept u64 bit counts in random.getrandbits(), matching CPython 3.15. Previously 2**31 was rejected on x86. Check the word allocation size and reserve fallibly before advancing the RNG. Use native-word arithmetic for frozenset hashing so equal sets agree with collections.abc.Set._hash(), which masks using sys.maxsize. Existing 64-bit results are unchanged. Use a fixed 64-bit slice-length prefix for byte/string hashing. This preserves existing x64 digests and fixes the existing fixed-key digest regression on x86; bytes, str, and memoryview remain hash-compatible. Add Rust regression coverage for allocation boundaries and set hashing. Only crates/common/src/hash.rs and crates/stdlib/src/random.rs change. C API, ctypes, PyO3, and CI are untouched. Validation Actual Windows x86 and x64 release runs: all 12 relevant modules pass on each architecture (2,143 tests run, 136 skipped): random, secrets, uuid, statistics, collections, set, dict, tuple, hash, dictviews, bytes, memoryview. x86 common hash unit tests: all 3 pass, including the previously failing fixed-key digest assertion. Full native workspace tests and all-targets Clippy with -D warnings pass, excluding wasm, venvlauncher, and C API. Separate C API Clippy passes. Separate C API tests were attempted but remain blocked by missing pythonXY.lib; no C API workaround is included. Formatting, pre-commit hooks, focused automated review, and CPython comparisons pass. Oversized/negative random requests raise the expected exception without changing RNG state. Investigation, implementation, validation, and focused automated review were assisted by Codex. The automated review is not human review. Summary by CodeRabbit Bug Fixes Improved hash consistency for byte sequences and set values. Improved handling of large getrandbits requests: unrepresentable or excessively large requests now return a memory error instead of proceeding with an invalid allocation. Allocation failures are also handled safely.
Open Graph Description: Summary Fix three reproducible Windows x86 compatibility failures without modifying Lib/ or existing test assertions: Accept u64 bit counts in random.getrandbits(), matching CPython 3.15. Previous...
X Description: Summary Fix three reproducible Windows x86 compatibility failures without modifying Lib/ or existing test assertions: Accept u64 bit counts in random.getrandbits(), matching CPython 3.15. Previous...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9437
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3abaab44-11e2-727f-6912-b108987deea0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A94E:3F8AB1:3EC4838:4FB29B6:6B01FA5F |
| html-safe-nonce | cda5c9ff8158df1b78ce088f6cd87fa6b0854662de4166294cb3d0b85895facc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTRFOjNGOEFCMTozRUM0ODM4OjRGQjI5QjY6NkIwMUZBNUYiLCJ2aXNpdG9yX2lkIjoiMjEyNTY4NjIyNjkxMTYyMzc3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 020a170a185da9425e07e463aee6bad26853d301a4227527ed31577562397ae1 |
| hovercard-subject-tag | pull_request:5052776350 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9437/files |
| twitter:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| og:image:alt | Summary Fix three reproducible Windows x86 compatibility failures without modifying Lib/ or existing test assertions: Accept u64 bit counts in random.getrandbits(), matching CPython 3.15. Previous... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width