Repository navigation
🐛 fix(backend): escape output the stdout encoding cannot represent - #330
Merged
gaborbernat merged 4 commits intoOct 28, 2026
Merged
Conversation
The backend prints its module and the hook arguments, which include project and output paths. Before Python 3.15 a Windows pipe uses the ANSI code page, so a path such as a Cyrillic folder name made print() raise UnicodeEncodeError and the build failed. Use backslashreplace for stdout, as stderr already does.
ty needs the suppression because typeshed declares sys.stdout as TextIO, which has no reconfigure(). Inline the single-use frontend in the test.
The fix lives in the backend module, so its test belongs in the backend test file, importing the frontend from the public package.
gaborbernat
enabled auto-merge (squash)
October 28, 2026 01:12
gaborbernat
disabled auto-merge
October 28, 2026 01:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

On Windows,
SubprocessFrontendandpython -m pyproject_apifailed when a path the backend prints contains a character outside the ANSI code page, for example a project in a Cyrillic folder on an English-locale machine. Python writes pipes in the ANSI code page on Windows, so the backend's progress messages raisedUnicodeEncodeErrorand the build stopped with a missing response file:🐛 The backend now writes such characters to standard output as backslash escapes, the same error handler Python already uses for standard error. This is the encoding-side counterpart of #311, which made the frontend tolerate bytes it cannot decode. tox is not affected because it sets
PYTHONIOENCODING=utf-8for the processes it runs.The setting applies only when the backend runs as its own process, so callers that import the backend module in-process keep their stream configuration.