-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis update modifies conditional compilation attributes for the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Poem
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. ✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
da332c8
to
bf4f6b9
Compare
There was a problem hiding this 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
⛔ 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.
#[allow(unused)] | ||
#[pymodule] | ||
mod pwd { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Narrow the lint scope; avoid blanket allow(unused).
Use a targeted allow only on Android or guard the specific import instead of silencing all unused warnings for the whole module.
Suggested change:
-#[allow(unused)]
+#[cfg_attr(target_os = "android", allow(unused_imports))]
Additionally, consider guarding or moving the NonNull import so you can drop the allow entirely on Android:
Option A (guard the import):
#[cfg(not(target_os = "android"))]
use std::ptr::NonNull;
Option B (move into the function and fully-qualify):
// remove the module-level `use std::ptr::NonNull;`
// inside getpwall:
while let Some(ptr) = std::ptr::NonNull::new(unsafe { libc::getpwent() }) {
// ...
}
This keeps clippy happy and avoids hiding unrelated issues.
🤖 Prompt for AI Agents
In vm/src/stdlib/pwd.rs around lines 5 to 7, the use of a blanket
#[allow(unused)] attribute on the entire module is too broad and hides unrelated
warnings. To fix this, remove the module-level #[allow(unused)] and instead
apply a more targeted approach by either guarding the import of
std::ptr::NonNull with #[cfg(not(target_os = "android"))] or by removing the
import entirely and fully qualifying std::ptr::NonNull inside the function where
it is used. This will narrow the lint scope and keep clippy warnings relevant.
@@ -2,6 +2,7 @@ | |||
|
|||
pub(crate) use pwd::make_module; | |||
|
|||
#[allow(unused)] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Summary by CodeRabbit