◐ Shell
clean mode source ↗

nt.skiproot, winapi.LCMapStringEx by youknowone · Pull Request #6399 · RustPython/RustPython

Walkthrough

This pull request adds Windows-specific functionality to the Rust VM: a CPython-like path splitting utility that decomposes Windows paths into drive, root, and tail components while preserving input type (str or bytes), and Windows API bindings for string locale mapping and named pipe creation with UTF-16 encoding/decoding support.

Changes

Cohort / File(s) Summary
Windows path utilities
crates/vm/src/stdlib/nt.rs
Added _path_splitroot_ex() function that accepts path-like inputs (str or bytes), normalizes slashes, computes drive and root segment lengths via skiproot() helper, and returns a 3-tuple of (drive, root, tail) while preserving input type and handling WTF-8 surrogates.
Windows API bindings
crates/vm/src/stdlib/winapi.rs
Added LOCALE_NAME_INVARIANT constant, LCMapStringEx() function for locale-aware string case mapping with Windows API integration and encoding validation, and CreateNamedPipe() function for creating named pipes with structured argument handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Specific areas for attention:
    • WTF-8 surrogate handling and UTF-16 round-trip encoding/decoding logic in both files
    • Windows path semantics in _path_splitroot_ex() including drive and UNC root detection
    • Error propagation and type validation across str/bytes input variants in nt.rs
    • Windows API call semantics and buffer handling in LCMapStringEx() (two-phase sizing pattern)
    • Argument struct CreateNamedPipeArgs field mapping to Windows CreateNamedPipeW() parameters

Poem

🐰 With paths now split on Windows wide,
And locale maps that shall not hide,
Named pipes dance through systems grand—
The VM grows stronger, isn't that grand!
UTF-16 surrogates handled with care,
New functions blooming everywhere! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'nt.skiproot, winapi.LCMapStringEx' directly references the two main functions being added, but lacks clarity about the purpose and nature of these additions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.