fix(windows): force utf8 for detached gateway - #60832
Closed
embwl0x wants to merge 1 commit into
Closed
Conversation
tonydwb
reviewed
Jul 8, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved (LGTM)
Forces PYTHONUTF8=1 alongside PYTHONIOENCODING=utf-8 for detached Windows gateway child environments. Covers Scheduled Task .cmd/.vbs launchers, direct detached argv, and post-update windowless restart specs.
Changes
- hermes_cli/init.py: _ensure_utf8() sets UTF-8 child env defaults on Windows even when pythonw has no stdio streams
- hermes_cli/gateway_windows.py: export PYTHONUTF8=1
- Tests: test_ensure_utf8_locale.py, test_gateway_windows.py, test_windows_native_support.py
Quality
- 5 files, 37 additions / 5 deletions
- Tests: all specified test suites pass
- Gitleaks clean
Reviewed by Hermes Agent
embwl0x
force-pushed
the
agent/fix-windows-detached-gateway-utf8
branch
from
July 10, 2026 09:19
f64fb57 to
b5faebc
Compare
embwl0x
marked this pull request as ready for review
July 10, 2026 09:19
embwl0x
force-pushed
the
agent/fix-windows-detached-gateway-utf8
branch
from
July 23, 2026 22:33
b5faebc to
c35d202
Compare
Contributor
|
Closing as superseded: the detached-gateway decode crash class was fixed on main by PRs #70850/#70875 (subprocess text-mode decode, incl. gateway_windows.py) and #71014 (bootstrap-level PYTHONUTF8 + platform._syscmd_ver stub in every entry point, desktop spawn env). The specific sites this PR touches are guarded on current main. Verified before closing. Thanks! |
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.
Fixes #60760.
Summary
PYTHONUTF8=1alongsidePYTHONIOENCODING=utf-8for detached Windows gateway child environments.cmdand.vbslaunchers, direct detached gateway argv, and post-update windowless restart specs_ensure_utf8()set UTF-8 child env defaults on Windows even whenpythonwhas no stdio streams to repairRoot Cause
Detached Windows gateways can run under
pythonwwithsys.stdoutandsys.stderrset toNone, so_ensure_utf8()had no stream to repair and never exported UTF-8 defaults for child processes. When a spawned child emitted UTF-8 text under a legacy ANSI locale such as GBK, Python's subprocess pipe reader could decode with the preferred locale and raiseUnicodeDecodeError.Tests
uv run --extra dev pytest tests/hermes_cli/test_ensure_utf8_locale.py tests/hermes_cli/test_gateway_windows.py tests/tools/test_windows_native_support.py::TestWindowlessGatewayRestartSpec -quv run --extra dev pytest tests/tools/test_windows_native_support.py -qSafety
gitleaks git --log-opts='origin/main..HEAD' --redact .: no leaks found