Update `os.py` from 3.13.5 by ShaharNaveh · Pull Request #6076 · RustPython/RustPython
Walkthrough
This change updates the POSIX standard library module by adding new constants for exit codes, refining conditional compilation attributes for platform-specific functions, and correcting the order and implementation of wait status inspection helpers to match POSIX conventions. No control flow or error handling logic is altered.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
POSIX stdlib module updatesvm/src/stdlib/posix.rs |
- Added new #[pyattr] constants for various POSIX exit codes.- Inserted blank lines for readability among grouped constants. - Updated conditional compilation attributes for user/group ID and session functions to further restrict platform support. - Reordered and renamed wait status inspection functions ( WIFSIGNALED, WCOREDUMP, WIFCONTINUED, etc.) and corrected their implementations to match POSIX semantics.- No changes to logic or error handling. |
Sequence Diagram(s)
No sequence diagrams are generated as the changes are limited to attributes, constants, and function reordering without affecting control flow.
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
Suggested reviewers
- youknowone
Poem
A bunny hopped through POSIX code,
Tidying constants in a neat abode.
Exit codes now line the wall,
With wait helpers standing tall.
Platform quirks, now well-defined—
In every hop, clarity you'll find!
🐇✨
Note
⚡️ Unit Test Generation is now available in beta!
Learn more here, or try it out under "Finishing Touches" below.
📜 Recent review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
Lib/os.pyis excluded by!Lib/**Lib/test/test_os.pyis excluded by!Lib/**
📒 Files selected for processing (1)
vm/src/stdlib/posix.rs(10 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style (cargo fmtto 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/posix.rs
🧠 Learnings (6)
📓 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: in rustpython's stat module implementation, platform-specific constants like sf_supported and sf_syn...
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/posix.rs
📚 Learning: in rustpython's stat module implementation, platform-specific constants like sf_supported and sf_syn...
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/posix.rs
📚 Learning: applies to **/*.rs : follow rust best practices for error handling and memory management...
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 : Follow Rust best practices for error handling and memory management
Applied to files:
vm/src/stdlib/posix.rs
📚 Learning: applies to **/*.rs : use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implement...
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/posix.rs
📚 Learning: in cargo build scripts (build.rs), the environment variable cargo_cfg_target_os is guaranteed to exi...
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/posix.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). (1)
- GitHub Check: Run snippets and cpython tests (windows-latest)
🔇 Additional comments (7)
vm/src/stdlib/posix.rs (7)
65-65: LGTM: Improved code readability.The added blank lines help visually separate different groups of imported constants, improving code organization.
Also applies to: 68-68, 72-72
85-130: LGTM: Properly implemented exit code constants.The new exit code constants correctly map from the
exitcodecrate to Python-accessible constants. The consistent pattern and type casting toi8is appropriate for exit codes.
143-143: LGTM: Consistent formatting improvements.The added blank lines provide visual separation between constant declarations, maintaining consistency with the formatting pattern used throughout the file.
Also applies to: 155-155, 166-166, 170-170, 174-174, 178-178, 182-182, 186-186
126-126: LGTM: Appropriate platform restrictions.The updated conditional compilation attributes correctly exclude
wasiandandroidtargets where these user/group ID functions are not available or restricted. This follows the established pattern of platform-specific function declarations and aligns with system capabilities.Also applies to: 132-132, 144-144, 190-190, 196-196, 202-202, 1300-1300
1631-1639: LGTM: Complete POSIX wait status inspection functions.The new
wcoredumpandwifcontinuedfunctions correctly implement the missing POSIX wait status inspection macros, following the established pattern and completing the standard set of wait status functions.
1646-1649: LGTM: Proper POSIX function ordering.Moving
wifsignaledto appear afterwifstoppedaligns the function order with POSIX conventions, improving standards compliance without affecting functionality.
1656-1669: LGTM: Critical correction of wait status functions.The corrected implementations ensure
wexitstatusandwtermsigcall their respective libc functions with proper POSIX naming conventions. This fixes a critical bug where the functions may have been calling incorrect underlying implementations.
✨ 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.
🪧 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.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.
- PR comments: Tag
@coderabbitaiin 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 src/utils.ts and explain its main purpose.@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 comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- 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.