| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
WalkthroughA new stat module has been added to the standard library, providing file status constants and functions for platform compatibility. The module is registered in the virtual machine. Related test overrides marked as expected failures have been removed, and "FIRMLINK" was added to the spelling whitelist. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant VM
participant stat_module
User->>VM: import _stat
VM->>stat_module: initialize via make_module
stat_module-->>VM: module instance with constants/functions
User->>stat_module: call filemode(mode)
stat_module-->>User: return permission string
Poem
📜 Recent review details Configuration used: CodeRabbit UI Reviewing files that changed from the base of the PR and between cca7e8a and 9a7507f. 📒 Files selected for processing (4)
Learnt from: moreal PR: RustPython/RustPython#5847 File: vm/src/stdlib/stat.rs:547-567 Timestamp: 2025-06-27T14:47:28.770Z 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. Learnt from: moreal PR: RustPython/RustPython#5847 File: vm/src/stdlib/stat.rs:547-567 Timestamp: 2025-06-27T14:47:28.770Z 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.770Z 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. Learnt from: moreal PR: RustPython/RustPython#5847 File: vm/src/stdlib/stat.rs:547-567 Timestamp: 2025-06-27T14:47:28.770Z 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: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory. Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate. Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible. Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: When comparing behavior with CPython, use the 'python' command explicitly for CPython and 'cargo run --' for RustPython to avoid confusion. Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository. Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code. Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: When testing Python code for RustPython, always use the RustPython interpreter (via 'cargo run -- script.py') instead of the standard 'python' command. Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython. [error] 137-137: End of file expected Use an array for a sequence of values: [1, 2] (parse) ⏰ Context from checks skipped due to timeout of 90000ms (10)
vm/src/stdlib/stat.rs (3)✨ Finishing Touches
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 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (.coderabbit.yaml)
Documentation and Community
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)vm/src/stdlib/stat.rs (1)📜 Review details310-321: Consider using const values directly instead of functions for constants.
The S_IMODE_method and S_IFMT_method functions use local const values that differ from the module-level constants. This could lead to confusion.
const S_IFMT: Mode = 0o170000; - const S_IMODE: Mode = 0o7777; + const S_IMODE_MASK: Mode = 0o7777; #[pyfunction(name = "S_IMODE")] #[allow(non_snake_case)] fn S_IMODE_method(mode: Mode) -> Mode { - mode & S_IMODE + mode & S_IMODE_MASK }
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Reviewing files that changed from the base of the PR and between b9b1c85 and cca7e8a.
📒 Files selected for processing (4)Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-26T12:52:11.109Z Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/os.rs (2)🪛 Biome (1.9.4) .cspell.jsonvm/src/stdlib/stat.rs (1)
- stat (508-540)
- stat (886-896)
- make_module (569-571)
[error] 137-137: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
⏰ Context from checks skipped due to timeout of 90000ms (9)vm/src/stdlib/mod.rs (2)17-17: LGTM! Module declaration follows the established pattern.
The stat module is properly declared following the same pattern as other standard library modules.
93-93: LGTM! Module registration follows the established pattern.
The stat module is correctly registered in the module initialization map with the appropriate "_stat" name, matching Python's convention.
vm/src/stdlib/stat.rs (4)1-14: LGTM! Module setup and type definitions are well-structured.
The platform-specific type definitions for Mode correctly handle Unix (using libc::mode_t), Windows (u16), and fallback cases (u32). The conditional compilation attributes are appropriate.
135-154: Android-specific handling looks correct.
The conditional compilation for S_IWRITE and S_IEXEC on Android is appropriate since these constants may not be available in Android's libc.
569-571: LGTM! Module creation function is implemented correctly.
The make_module function follows the established pattern for creating Python modules in RustPython.
93-98: Verify that S_ENFMT should use the same value as S_ISGID.
The S_ENFMT constant is defined as libc::S_ISGID on Unix and 0o2000 on non-Unix, which matches S_ISGID. Please confirm this is intentionally the same value.
#!/bin/bash # Description: Verify S_ENFMT definition in system headers and CPython # Expected: S_ENFMT should be the same as S_ISGID on most systems # Check system headers for S_ENFMT definition rg -A 2 -B 2 "S_ENFMT" /usr/include/ 2>/dev/null || echo "S_ENFMT not found in system headers" # Search for S_ENFMT in the CPython source to understand the expected behavior echo "Checking CPython's stat module implementation..."
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you! And welcome back!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary by CodeRabbit
New Features
Tests
Chores