Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix encoding mismatch between python child process and uv (#7757)
## Summary This PR fixes #7733. According to [CPython documentation on `sys.stdout`](https://docs.python.org/3.12/library/sys.html#sys.stdout), when `stdout`/`stderr` is non-character device like pipe, the encoding will be set to system locale on windows. However, on the Rust side `stdout_reader` and `stderr_reader` expect them to be encoded in UTF-8 and will fail when child process write non-ASCII character to stdout/stderr, e.g., build directory name containing non-ASCII character. Both [CPython3](https://docs.python.org/3.12/using/cmdline.html#envvar-PYTHONIOENCODING) and [PyPy](https://doc.pypy.org/en/default/man/pypy3.1.html#environment) support environment variable `PYTHONIOENCODING`. When it is set to `utf-8`, python will use UTF-8 encoding for `stdin`/`stdout`/`stderr`. Since `stdin` is not used by the spawned python process and we expect `stdout`/`stderr` to use UTF-8, this fix should work as expected. <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan I only tested it on my computer with CPython 3.12 and 3.7. With the fix applied I confirmed that [the case I described](#7733 (comment)) is fixed. I'm using Windows 11 with system locale set to code page 936.
- Loading branch information