fix: add encoding=utf-8, errors=replace to all subprocess text=True calls (#53428) - #53460
fix: add encoding=utf-8, errors=replace to all subprocess text=True calls (#53428)#53460Sahil-SS9 wants to merge 2 commits into
Conversation
Related: this is the broadest entry in the Windows non-UTF-8 (CP936/GBK/cp950) subprocess-encoding rollout — 20 sites across 12 files. It overlaps with focused open PRs on individual sites: #52700 ( |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Adds encoding="utf-8", errors="replace" to all 20 subprocess.run/Popen calls with text=True across 12 files. Fixes Chinese Windows (CP936/GBK) encoding crashes that cascade into TUI freezes and gateway restarts.
- 20 additions, 20 deletions — pure mechanical change
- 12 files touched but all are the same type of change
- Under 15-file surface-area threshold
errors="replace"is the right choice for robustness (graceful degradation)- Fixes a real cross-platform bug (#53428)
Reviewed by Hermes Agent
|
Closing as superseded by the consolidated Windows console-flash work tracked in #54220. The relevant pieces from this PR/cluster have now landed through the targeted follow-up PRs #54236, #53892, and #54417, or are recorded in the umbrella tracker for any remaining native-Windows verification. Keeping this separate PR open would duplicate the tracker and the merged follow-up work. Thanks for digging into this — the reports and PRs in this cluster helped identify the remaining spawn legs. |
Fixes #53428
Description
On Chinese Windows (CP936/GBK default encoding), any
subprocess.run/Popenwithtext=Truebut no explicitencoding/errors params crashes_readerthreadwhen child outputs UTF-8 Chinese text, triggering a cascading failure chain that eventually freezes the TUI and restarts the gateway.This adds
encoding="utf-8", errors="replace"to all 20 locations across 12 files wheresubprocess.run/Popenusestext=Truewithout an explicit encoding parameter.Files changed (12 files, 20 locations)
tui_gateway/server.py(5) — ACP child process, pdftoppm,hermessubprocess, quick commands, shell exectui_gateway/git_probe.py(1) — git probinggateway/run.py(1) — systemctl showagent/coding_context.py(1) — git helperagent/anthropic_adapter.py(1) — security credential lookupagent/context_references.py(2) — git and ripgrep helpersagent/lsp/install.py(3) — npm, go, pip installersagent/secret_sources/bitwarden.py(2) — ldd probe, bws runagent/copilot_acp_client.py(1) — ACP subprocessagent/shell_hooks.py(1) — shell hook executionagent/skill_preprocessing.py(1) — inline shell executionagent/transports/codex_app_server.py(1) — codex version checkVerification
python3 /tmp/find_missing_encoding.py # 0 results — all locations fixed