Fix getrandom 0.4.0 upgrade compatibility by updating mt19937 to v3.3.0#6971
Fix getrandom 0.4.0 upgrade compatibility by updating mt19937 to v3.3.0#6971Copilot wants to merge 5 commits intodependabot/cargo/getrandom-0.4.0from
Conversation
Bumps [getrandom](https://github.com/rust-random/getrandom) from 0.3.4 to 0.4.0. - [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md) - [Commits](rust-random/getrandom@v0.3.4...v0.4.0) --- updated-dependencies: - dependency-name: getrandom dependency-version: 0.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
The upgrade to getrandom 0.4.0 caused a compilation error because mt19937 depends on getrandom 0.3.4 via rand_core, creating a version mismatch. The code tried to convert getrandom::Error from 0.3.4 to std::io::Error using From trait, but the implementation expected getrandom 0.4.0's Error. Fixed by using std::io::Error::other() to create the error manually, avoiding the version-specific From trait implementation. Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot also check wasm CI failure |
The WASM build was failing because getrandom 0.3.4 (transitive dependency from mt19937 and ahash) requires the wasm_js feature to be enabled when compiling for wasm32-unknown-unknown target. Changes: - Add wasm_js feature to rustpython-stdlib that passes through to rustpython-common - Enable wasm_js feature in rustpython-wasm for rustpython-stdlib dependency - Add explicit getrandom 0.3 dependency with wasm_js feature for WASM targets in rustpython-stdlib This ensures all versions of getrandom (0.3.4 and 0.4.0) have the wasm_js feature enabled when building for WASM. Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
The WASM CI was failing because getrandom 0.3.4 (transitive dependency from mt19937 and ahash) requires the Fixed in commit aa09bb7 by:
The WASM build now compiles successfully. |
4cbdf68 to
77fab36
Compare
|
ref: RustPython/mt19937#4 |
77fab36 to
869548f
Compare
|
@copilot you shoudn't use getrandom 0.3.0; to make sure CI passes, replace our mt19937 dependency to this git version: RustPython/mt19937#9 |
Per user request, replaced the workaround of using getrandom 0.3 with upgrading to mt19937 v3.3.0 from git (branch: version) which uses rand_core 0.10 and is compatible with getrandom 0.4.0. Changes: - Update mt19937 dependency to git version 3.3.0 (branch: version) - Update rand_core workspace dependency from 0.9 to 0.10 - Add getrandom workspace dependency with sys_rng feature enabled - Add getrandom to rustpython-stdlib dependencies - Update random.rs to use new rand_core 0.10 API: - Import Rng trait instead of RngCore - Use MT19937::try_from_rng(&mut getrandom::SysRng) instead of try_from_os_rng() - Keep getrandom 0.3 with wasm_js feature for WASM targets (needed by ahash) The random module now uses the latest mt19937 with proper getrandom 0.4 support. Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
Updated to use mt19937 v3.3.0 from git (branch: version) in commit d7cb107. This version uses rand_core 0.10 which is compatible with getrandom 0.4.0. Also updated the random.rs code to use the new rand_core 0.10 API (Rng trait and MT19937::try_from_rng with getrandom::SysRng). Both regular and WASM builds now pass successfully. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
The getrandom 0.3.4→0.4.0 upgrade fails due to incompatibilities with the existing mt19937 v3.1 dependency. This PR upgrades to mt19937 v3.3.0 which uses rand_core 0.10 and is fully compatible with getrandom 0.4.0.
Changes
Updated Dependencies
3.1to git version3.3.0(branch:versionfrom https://github.com/RustPython/mt19937)0.9to0.10sys_rngfeature to workspace dependency (required for SysRng type)Random Module Updates
crates/stdlib/src/random.rsto use rand_core 0.10 API:Rngtrait instead of deprecatedRngCoreMT19937::try_from_rng(&mut getrandom::SysRng)instead oftry_from_os_rng()std::io::Error::other()for version-agnostic error creationWASM Build Support
getrandom = { version = "0.3", features = ["wasm_js"] }dependency for WASM targets inrustpython-stdlibahash v0.8.12(transitive dependency) still uses getrandom 0.3Testing
The solution properly addresses the getrandom 0.4.0 compatibility by using the updated mt19937 version rather than workarounds.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.