Skip to content

Use correct dirs crate; drop uname for rustix#7906

Open
joshuamegnauth54 wants to merge 1 commit into
RustPython:mainfrom
joshuamegnauth54:dirs-and-drop-uname
Open

Use correct dirs crate; drop uname for rustix#7906
joshuamegnauth54 wants to merge 1 commit into
RustPython:mainfrom
joshuamegnauth54:dirs-and-drop-uname

Conversation

@joshuamegnauth54
Copy link
Copy Markdown
Contributor

@joshuamegnauth54 joshuamegnauth54 commented May 17, 2026

RustPython used an ancient, unmaintained version of the dirs crate. This pulled in winapi-rs on Windows, which is an old crate that has been deprecated in favor of windows-rs. windows-rs is maintained by Microsoft. Bumping dirs to the latest version removes more winapi-rs from Cargo.lock.

As for uname, rustix handles it safely so the additional crate isn't needed.

Summary by CodeRabbit

  • Chores

    • Updated the directory-handling library dependency to a newer implementation.
    • Removed an unused system utility dependency.
  • Refactor

    • Improved system information retrieval to surface explicit UTF-8 decode errors.
    • POSIX bindings now map failures to Unicode decode errors for clearer diagnostics.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 83dc06fd-5e88-4af3-87bb-d3fa34717761

📥 Commits

Reviewing files that changed from the base of the PR and between 1085c9c and d813ce5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • Cargo.toml
  • crates/host_env/Cargo.toml
  • crates/host_env/src/posix.rs
  • crates/vm/src/stdlib/posix.rs
💤 Files with no reviewable changes (1)
  • crates/host_env/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (2)
  • Cargo.toml
  • crates/host_env/src/posix.rs

📝 Walkthrough

Walkthrough

Upgrades workspace dirs to crate dirs = "6", removes the uname dependency, migrates host_env uname lookup to rustix::system::uname() (propagating UTF-8 conversion errors), and maps those errors to Python Unicode decode errors in the stdlib binding.

Changes

System dependency and uname migration

Layer / File(s) Summary
Dependency manifest updates
Cargo.toml, crates/host_env/Cargo.toml
Replace dirs-next with dirs = "6" in workspace manifest and remove uname = "0.1.1" from crates/host_env unix target dependencies.
uname_info implementation
crates/host_env/src/posix.rs
Use rustix::system::uname() and convert fields with to_str()?, changing uname_info() to return Result<UnameInfo, core::str::Utf8Error>.
Python stdlib adapter
crates/vm/src/stdlib/posix.rs
Map errors from rustpython_host_env::posix::uname_info() to vm.new_unicode_decode_error(err.to_string()) in the uname() binding.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • RustPython/RustPython#7799: Implements a similar migration to rustix::system::uname() and related error/field conversion changes.

Suggested reviewers

  • youknowone
  • ShaharNaveh

Poem

🐰 I hopped from crate to crate tonight,

swapped dirs and let uname take flight.
rustix whispers strings so neat,
UTF‑8 keeps errors discrete.
A tiny hop — dependency light.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: updating the dirs crate and removing the uname dependency in favor of rustix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@ShaharNaveh ShaharNaveh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into it:)

LGTM!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/vm/src/stdlib/posix.rs`:
- Around line 1282-1283: The code maps errors from
rustpython_host_env::posix::uname_info() to vm.new_unicode_encode_error, but
this path is decoding OS bytes and should raise UnicodeDecodeError instead;
update the mapping to call vm.new_unicode_decode_error(err.to_string())
(mirroring the getlogin() handling) so Utf8Error is surfaced as a
UnicodeDecodeError, keeping the same error text and propagation semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: c292b93c-a588-4a4a-8bb7-9bbf959ea083

📥 Commits

Reviewing files that changed from the base of the PR and between 883ce9d and 1085c9c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • Cargo.toml
  • crates/host_env/Cargo.toml
  • crates/host_env/src/posix.rs
  • crates/vm/src/stdlib/posix.rs
💤 Files with no reviewable changes (1)
  • crates/host_env/Cargo.toml

Comment thread crates/vm/src/stdlib/posix.rs Outdated
RustPython used an ancient, unmaintained version of the `dirs` crate.
This pulled in `winapi-rs` on Windows, which is an old crate that has
been deprecated in favor of `windows-rs`. `windows-rs` is maintained by
Microsoft. Bumping `dirs` to the latest version removes more `winapi-rs`
from Cargo.lock.

As for `uname`, `rustix` handles it safely so the additional crate isn't
needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants