-
Notifications
You must be signed in to change notification settings - Fork 1.4k
winapi suppliment #6338
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
winapi suppliment #6338
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThree Windows stdlib modules are enhanced with new API bindings: GetErrorMode() function added to msvcrt, three IO_REPARSE_TAG_* constants added to stat under Windows cfg, and winapi.rs receives updated GetStdHandle/DuplicateHandle signatures plus new ExitProcess function. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (3)
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. Comment |
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: 2
🧹 Nitpick comments (2)
crates/vm/src/stdlib/codecs.rs (2)
239-316: Consider overflow check for large strings (optional).The implementation correctly handles MBCS encoding with proper surrogate checking, two-pass buffer sizing, and strict error handling. However, the casts from
wide.len()toi32(lines 270, 291) could theoretically overflow for extremely large strings (> 2GB).This is unlikely in practice and aligns with similar limitations in CPython's implementation.
436-513: Consider overflow check (optional); note code duplication.The
oem_encodeimplementation is nearly identical tombcs_encode(differing only in usingCP_OEMCPinstead ofCP_ACP). The same optional consideration applies regarding potentiali32overflow for extremely large strings.Optional refactor: Consider extracting a common helper function to reduce duplication between
mbcs_encodeandoem_encode.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Lib/test/test_faulthandler.pyis excluded by!Lib/**Lib/test/test_shutil.pyis excluded by!Lib/**Lib/test/test_subprocess.pyis excluded by!Lib/**
📒 Files selected for processing (5)
crates/vm/src/stdlib/codecs.rs(1 hunks)crates/vm/src/stdlib/msvcrt.rs(1 hunks)crates/vm/src/stdlib/stat.rs(1 hunks)crates/vm/src/stdlib/winapi.rs(4 hunks)crates/vm/src/windows.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- crates/vm/src/stdlib/msvcrt.rs
- crates/vm/src/stdlib/stat.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint Rust code (cargo clippy) before completing tasks and fix any warnings or lints introduced by 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:
crates/vm/src/stdlib/winapi.rscrates/vm/src/stdlib/codecs.rscrates/vm/src/windows.rs
🧠 Learnings (1)
📓 Common learnings
Learnt from: moreal
Repo: RustPython/RustPython PR: 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.
Learnt from: moreal
Repo: RustPython/RustPython PR: 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.
🧬 Code graph analysis (2)
crates/vm/src/stdlib/winapi.rs (1)
crates/vm/src/stdlib/os.rs (1)
errno_err(39-41)
crates/vm/src/stdlib/codecs.rs (1)
crates/vm/src/stdlib/nt.rs (1)
from_utf16(327-329)
⏰ 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). (9)
- GitHub Check: Check Rust code with clippy
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Ensure compilation on various targets
🔇 Additional comments (4)
crates/vm/src/windows.rs (1)
172-172: LGTM! Correct symlink file type handling.The change properly clears existing file type bits using
S_IFMTmask before setting the Windows-specific symlink type. This prevents invalid combined file type bits that could result from OR-ing with the previous mode.crates/vm/src/stdlib/winapi.rs (3)
88-102: LGTM! Proper handle error and null handling.The refactored
GetStdHandlecorrectly distinguishes between:
INVALID_HANDLE_VALUE→ returns error viaerrno_err(vm)NULLhandle → returnsNone(e.g., detached console)- Valid handle → returns
Some(HANDLE)This pattern aligns with Rust idioms and provides proper error propagation to Python.
127-128: LGTM! Improved API ergonomics.Splitting the source handle into two separate parameters (
src_processandsrc) instead of a tuple makes the API more intuitive and idiomatic.
308-311: LGTM! ExitProcess added for process termination.The function exposes Windows'
ExitProcessAPI, which terminates the process immediately without running destructors or cleanup handlers. This is analogous to Python'sos._exit()and is appropriate for the low-level_winapimodule.
Summary by CodeRabbit
Release Notes
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.