fix(tui_gateway): set utf-8 encoding for subprocess pipes on Windows - #67922
Closed
escalate007 wants to merge 1 commit into
Closed
fix(tui_gateway): set utf-8 encoding for subprocess pipes on Windows#67922escalate007 wants to merge 1 commit into
escalate007 wants to merge 1 commit into
Conversation
On Chinese Windows systems, subprocess.Popen with text=True defaults to GBK encoding for pipe reads. When the Hermes backend writes UTF-8 bytes to stderr, the _drain_stderr thread crashes with UnicodeDecodeError, making the desktop UI unresponsive after file uploads. Fix by adding encoding='utf-8' to the Popen call.
Collaborator
Contributor
|
Closing as superseded by PR #70850 (merged), which covers this Popen site plus every other |
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.
Problem
On Chinese Windows systems (GBK system encoding),
subprocess.Popenwithtext=Truedefaults to the system locale for pipe decoding. When the Hermes backend writes UTF-8 bytes to stderr, the_drain_stderrthread crashes withUnicodeDecodeError: 'gbk' codec can't decode byte. This makes the desktop/TUI backend unresponsive — the user clicks send after uploading a file and nothing happens.Root cause
tui_gateway/server.pyline 339:text=Truewithout an explicitencoding=. Python uses the locale encoding (GBK on zh-CN Windows), but the backend process outputs UTF-8.Fix
Add
encoding='utf-8'to the Popen call, aftertext=True. This is a one-line change, safe on all platforms — Python ignores unknown encoding parameters on non-Windows systems where UTF-8 is already the default.Related logs
And also Python's internal
_readerthreadinsubprocess.py:UnicodeDecodeError: 'gbk' codec can't decode byte 0x94 in position 140: illegal multibyte sequence