Fix locale.getencoding, overlapped.getresult, chdir for windows by youknowone · Pull Request #6629 · RustPython/RustPython
📝 Walkthrough
Walkthrough
This pull request introduces three platform-specific enhancements to stdlib modules: a locale encoding detection function with Windows/Unix/mobile fallbacks, an overlapped I/O result synchronization method with complex error handling, and per-drive environment variable propagation in the Windows chdir implementation.
Changes
| Cohort / File(s) | Summary |
|---|---|
Locale module enhancement crates/stdlib/src/locale.rs |
Added getencoding() function with platform-aware logic: returns cp{ACP} on Windows via GetACP(), queries CODESET via nl_langinfo on Unix systems with UTF-8 fallback, and returns UTF-8 on iOS/Android/Redox. |
Overlapped I/O synchronization crates/stdlib/src/overlapped.rs |
Added Overlapped.getresult() method to retrieve results from overlapped operations. Includes new helper for parsing SOCKADDR_IN6, nuanced error handling for Windows error codes (e.g., ERROR_BROKEN_PIPE, ERROR_IO_PENDING), and stateful return logic based on operation type (Read, Write, ReadFrom, etc.). |
Windows chdir environment variable propagation crates/vm/src/stdlib/os.rs |
Extended Windows chdir implementation to set per-drive environment variables (e.g., =X:) after changing the process working directory, with UNC path detection to skip environment variable setting for network paths. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- Fix test_subprocess and locale #6416: Modifies
crates/stdlib/src/locale.rswith Windows-specific locale additions, directly overlapping with the locale encoding changes in this PR. - Update
locale.pyfrom 3.13.6 and made_localeavailable on android #6091: Updatescrates/stdlib/src/locale.rswith platform-specific conditional compilation and module exports on Android, sharing the same file and similar platform-guarding patterns. - test_os, test_io on windows #6379: Adjusts environment variable handling for names starting with
=in Windows (putenv/unsetenv), directly related to the per-drive environment variable logic introduced inchdir.
Suggested reviewers
- ShaharNaveh
Poem
🐰 New paths reveal their secrets true,
From Windows codes to overlapped queues,
Each platform sings a different song,
As locale and I/O march along! ✨
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 title accurately describes the main changes: adding/fixing three Windows-related features (locale.getencoding, overlapped.getresult, and chdir) across three files in the codebase. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- 📝 Generate docstrings
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 @coderabbitai help to get the list of available commands and usage tips.