Title: Fix deprecated constant and method usage in `host_env` and `vm` crates. · Issue #8297 · RustPython/RustPython · GitHub
Open Graph Title: Fix deprecated constant and method usage in `host_env` and `vm` crates. · Issue #8297 · RustPython/RustPython
X Title: Fix deprecated constant and method usage in `host_env` and `vm` crates. · Issue #8297 · RustPython/RustPython
Description: While compiling RustPython (specifically rustpython-host_env v0.5.0 and the vm crate), several deprecation warnings are emitted. While these do not currently break the build, they introduce technical debt, clutter CI logs, and pose poten...
Open Graph Description: While compiling RustPython (specifically rustpython-host_env v0.5.0 and the vm crate), several deprecation warnings are emitted. While these do not currently break the build, they introduce technic...
X Description: While compiling RustPython (specifically rustpython-host_env v0.5.0 and the vm crate), several deprecation warnings are emitted. While these do not currently break the build, they introduce technic...
Opengraph URL: https://github.com/RustPython/RustPython/issues/8297
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fix deprecated constant and method usage in `host_env` and `vm` crates.","articleBody":"While compiling RustPython (specifically `rustpython-host_env v0.5.0` and the `vm` crate), several deprecation warnings are emitted. While these do not currently break the build, they introduce technical debt, clutter CI logs, and pose potential stability and portability risks if left unaddressed.\n\n## Context \u0026 Compiler Output\nThe following warnings are generated during compilation:\n\n**1. `libc::RLIM_NLIMITS` deprecation in `host_env`**\n```text\nwarning: use of deprecated constant `libc::RLIM_NLIMITS`: Not stable across OS versions\n --\u003e crates/host_env/src/resource.rs:11:15\n |\n11 | pub use libc::RLIM_NLIMITS;\n | ^^^^^^^^^^^^\n```\n\n**2. `Atomic::fetch_update` deprecation in `vm`**\n```text\nwarning: use of deprecated method `rustpython_common::atomic::Atomic::\u003cu32\u003e::fetch_update`: renamed to `try_update` for consistency\n --\u003e crates/vm/src/builtins/function.rs:90:10\n |\n90 | ... .fetch_update(Relaxed, Relaxed, |v| (v != 0)...\n | ^^^^^^^^^^^^\n\nwarning: use of deprecated method `rustpython_common::atomic::Atomic::\u003cu64\u003e::fetch_update`: renamed to `try_update` for consistency\n --\u003e crates/vm/src/builtins/type.rs:683:14\n |\n683| ... .fetch_update(Ordering::AcqRel, Ordering::A...\n | ^^^^^^^^^^^^\n```\n\n## Risks Involved\n\n### 1. Cross-Platform Instability (`RLIM_NLIMITS`)\nThe `libc` crate explicitly marks `RLIM_NLIMITS` as deprecated because **it is not stable across OS versions**. The number of resource limits (`RLIMIT_*`) varies between different operating systems and even across different versions of the same OS (e.g., Linux kernel updates). \n* **Risk:** Relying on this constant as a boundary for iterating over resource limits can lead to out-of-bounds errors, incorrect resource limit calculations, or panics when RustPython is compiled for or run on newer/older OS versions. It severely hinders cross-platform reliability.\n\n### 2. Codebase Confusion and Future Breakage (`fetch_update`)\nThe internal `rustpython_common::atomic::Atomic` wrapper renamed `fetch_update` to `try_update` for API consistency (likely to avoid confusion with the standard library's `std::sync::atomic::Atomic*::fetch_update`).\n* **Risk:** While currently just a warning, keeping deprecated methods in the codebase causes \"warning fatigue\" in CI. If the deprecated `fetch_update` method is eventually removed from `rustpython_common` in a future minor release, it will cause hard compilation failures. Furthermore, it confuses contributors who might look up the standard library's `fetch_update` and expect it to behave identically to the custom wrapper.\n\n## Proposed Solutions\n\n### Fix 1: Replace `RLIM_NLIMITS` in `crates/host_env/src/resource.rs`\nInstead of exporting or using `RLIM_NLIMITS` as a generic upper bound, we should handle resource limits dynamically or use explicit constants.\n* **Action:** Investigate how `RLIM_NLIMITS` is being used in `resource.rs`. If it's used to iterate over all possible limits, refactor the code to use an explicit array of supported `RLIMIT_*` constants for the target OS, or use conditional compilation (`#[cfg(target_os = \"...\")]`) to handle OS-specific maximums safely. Remove the `pub use libc::RLIM_NLIMITS;` export.\n\n### Fix 2: Rename `fetch_update` to `try_update` in `vm`\nThis is a straightforward find-and-replace to align with the updated `rustpython_common` API.\n* **Action:** Update the method calls in the following files:\n * `crates/vm/src/builtins/function.rs` (Line 90)\n * `crates/vm/src/builtins/type.rs` (Line 683)\n\n**Example diff for `function.rs`:**\n```diff\n- .fetch_update(Relaxed, Relaxed, |v| (v != 0).then(|| v.wrapping_add(1)))\n+ .try_update(Relaxed, Relaxed, |v| (v != 0).then(|| v.wrapping_add(1)))\n```\n\n**Example diff for `type.rs`:**\n```diff\n- .fetch_update(Ordering::AcqRel, Ordering::Acquire, |old| {\n+ .try_update(Ordering::AcqRel, Ordering::Acquire, |old| {\n```\n\n## Action Items\n- [ ] Refactor `crates/host_env/src/resource.rs` to remove reliance on `libc::RLIM_NLIMITS`.\n- [ ] Rename `fetch_update` to `try_update` in `crates/vm/src/builtins/function.rs`.\n- [ ] Rename `fetch_update` to `try_update` in `crates/vm/src/builtins/type.rs`.\n- [ ] Run `cargo build` and `cargo test` to ensure no regressions and verify that the deprecation warnings are gone.","author":{"url":"https://github.com/human-on-vm","@type":"Person","name":"human-on-vm"},"datePublished":"2026-07-17T01:04:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/8297/RustPython/issues/8297"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5db2e714-2bc0-cf1c-bc05-6be2438534cc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B080:2B266B:273B76:353562:6A614B4C |
| html-safe-nonce | 5e1d4702832fe5cf82dd3a79a9bdb40ca966c159434627f06aa56317a1c1fe02 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDgwOjJCMjY2QjoyNzNCNzY6MzUzNTYyOjZBNjE0QjRDIiwidmlzaXRvcl9pZCI6IjY0Njc2NTg3NjE2ODAwMTQxNTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0008f80d2b00e1a70652f3c75420133bd549e795fe9adbe33afb8a78136f9b76 |
| hovercard-subject-tag | issue:4907157548 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/RustPython/RustPython/8297/issue_layout |
| twitter:image | https://opengraph.githubassets.com/60b47e305f77c47a8c39607dddfdeb66ccd493e0429556888d6832629d43e054/RustPython/RustPython/issues/8297 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/60b47e305f77c47a8c39607dddfdeb66ccd493e0429556888d6832629d43e054/RustPython/RustPython/issues/8297 |
| og:image:alt | While compiling RustPython (specifically rustpython-host_env v0.5.0 and the vm crate), several deprecation warnings are emitted. While these do not currently break the build, they introduce technic... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | human-on-vm |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4876c15b81beff1a5306612a3386748550c731559f1dbbe4cf7146fda63fc0e0 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3e1bd3b6ebab0d27ffbef3a6bbb1043bc5f098ae |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width