Repository navigation
Description
Preflight
- I searched existing issues and discussions for this behavior.
- This report is not an unpatched security vulnerability.
- The report and attachments contain no credentials or private/internal material.
Issue origin
Observed or reproduced in a real environment
LoopX version or commit
c2b17b3 (loopx 1.3.1)
Host or runtime surface
Not host-specific
LoopX area
Host or runtime integration
Problem
The shipped CLI never pins its own stdio to UTF-8, so on a host whose locale codec is not UTF-8 (cp936/GBK on zh-CN Windows, or any host under PYTHONIOENCODING=gbk) the process uses that codec for its own stdin/stdout/stderr. LoopX already pins UTF-8 for every text-mode file read/write (tests/test_loopx_text_io_utf8.py) and text-mode subprocess call (tests/test_runtime_subprocess_utf8.py); the process's own streams are the remaining locale-dependent surface.
Effect: any non-ASCII text the CLI prints - an issue title, a scan path or other echoed argument, the 🔴 alert marker used by loopx status - raises UnicodeEncodeError, so the command exits non-zero with no output on stdout. --metadata-json - additionally decodes UTF-8 stdin with the locale codec, so the same input gives different results through the stdin and file routes.
Minimal reproduction
On Windows with a zh-CN (cp936) console, or any host with PYTHONIOENCODING=gbk:
- Write
metadata.jsoncontaining{"number": 123, "state": "open", "title": "🚀 修复 deploy"}(UTF-8). - Run
loopx --runtime-root <tmp> --format json content-ops issue-fix-metadata-preview --url https://github.com/huangruiteng/loopx/issues/123 --metadata-json metadata.json.
Expected behavior
The command prints its UTF-8 JSON payload (with the non-ASCII title intact) and exits 0, regardless of the host locale codec.
Actual behavior
Exit 1 with no stdout, and:
File ".../loopx/cli_runtime.py", line 99, in print_payload
print(json.dumps(payload, ensure_ascii=False, indent=2))
UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f680' in position 705: illegal multibyte sequence
Sanitized diagnostics
python -c "import sys; print(sys.stdout.encoding, sys.flags.utf8_mode)"
gbk 0
# PYTHONIOENCODING / PYTHONUTF8 unset
Setting PYTHONIOENCODING=utf-8 makes the same command succeed, which confirms the process's own stdio codec is the cause.
Additional context
Same defect class as #4941 (file text I/O) and #4155 (subprocess decode). A fix that pins the shipped CLI's own stdio to UTF-8 will follow as a pull request.
Activity
docs(cli): disclose the entrypoint UTF-8 stdio behavior change
fix(cli): pin the shipped CLI's own stdio to UTF-8