Skip to content

Update netrc.py from 3.13.6 and make pwd accesible on Android #6083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ShaharNaveh
Copy link
Contributor

@ShaharNaveh ShaharNaveh commented Aug 8, 2025

Summary by CodeRabbit

  • Refactor
    • Adjusted platform availability for the password/user-info feature so it is excluded on additional targets (iOS, WASI and Redox) and refines behavior on Android, improving platform compatibility and build correctness.

Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

Conditional compilation for the pwd module in the standard library was updated to exclude iOS, WASI, and Redox; the module registration in get_module_inits was changed accordingly. In pwd.rs, an Android-specific unused-import allowance was added and getpwall was gated out on Android.

Changes

Cohort / File(s) Change Summary
Stdlib module conditional compilation
vm/src/stdlib/mod.rs
Updated conditional compilation attributes for the pwd module declaration and its entry in get_module_inits to use #[cfg(all(unix, not(any(target_os = "ios", target_os = "wasi", target_os = "redox"))))].
Pwd module adjustments
vm/src/stdlib/pwd.rs
Added #[cfg_attr(target_os = "android", allow(unused_imports))] to the module, inserted a blank line after the Passwd struct, and gated getpwall with #[cfg(not(target_os = "android"))].

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit nudges lines with care,
Guarding platforms here and there.
"Skip pwd on iOS and WASI, please,"
Android hushes getpwall with ease.
Hops of change beneath the trees 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf4f6b9 and 2ff5885.

📒 Files selected for processing (1)
  • vm/src/stdlib/pwd.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • vm/src/stdlib/pwd.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run tests under miri
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ShaharNaveh ShaharNaveh marked this pull request as ready for review August 8, 2025 13:14
Copy link
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

🧹 Nitpick comments (2)
vm/src/stdlib/mod.rs (2)

50-54: LGTM: enable pwd on Android; exclude on iOS/WASI/Redox.

The cfg aligns with platform availability and mirrors CPython’s behavior more closely.

Consider a brief comment explaining why iOS/WASI/Redox are excluded to help future maintainers.


128-132: LGTM: consistent cfg for module registration.

The init map condition matches the module declaration cfg, avoiding mismatches at link time.

Update the preceding “Unix-only” comment to reflect exceptions (iOS/WASI/Redox) for clarity.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e922722 and bf4f6b9.

⛔ Files ignored due to path filters (2)
  • Lib/netrc.py is excluded by !Lib/**
  • Lib/test/test_netrc.py is excluded by !Lib/**
📒 Files selected for processing (2)
  • vm/src/stdlib/mod.rs (2 hunks)
  • vm/src/stdlib/pwd.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.rs: Follow the default rustfmt code style (cargo fmt to format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust

Files:

  • vm/src/stdlib/pwd.rs
  • vm/src/stdlib/mod.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
📚 Learning: 2025-06-28T16:31:03.991Z
Learnt from: arihant2math
PR: RustPython/RustPython#5790
File: build.rs:2-2
Timestamp: 2025-06-28T16:31:03.991Z
Learning: In Cargo build scripts (build.rs), the environment variable CARGO_CFG_TARGET_OS is guaranteed to exist and is automatically set by Cargo during the build process, making unwrap() safe to use when accessing this variable.

Applied to files:

  • vm/src/stdlib/pwd.rs
  • vm/src/stdlib/mod.rs
📚 Learning: 2025-07-19T03:16:56.511Z
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust

Applied to files:

  • vm/src/stdlib/pwd.rs
  • vm/src/stdlib/mod.rs
📚 Learning: 2025-06-27T14:47:28.810Z
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.

Applied to files:

  • vm/src/stdlib/mod.rs
📚 Learning: 2025-06-27T14:47:28.810Z
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.

Applied to files:

  • vm/src/stdlib/mod.rs
🔇 Additional comments (2)
vm/src/stdlib/pwd.rs (2)

30-30: No-op change.

Blank line only; nothing to review.


96-113: LGTM: gate getpwall on Android.

Excluding getpwall on Android matches bionic’s lack of getpwent and avoids link errors while keeping pwd available on Android.

If CI doesn’t already, please add an Android target check to ensure nix::unistd::User::{from_name,from_uid} build and run as expected on Android.

@@ -2,6 +2,7 @@

pub(crate) use pwd::make_module;

#[allow(unused)]
Copy link
Member

Choose a reason for hiding this comment

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

Because the conditions in stdlib/mod.rs must be aligned, this allow will not be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's only being used on android.
I can do what coderabbitai is suggesting if that's ok

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