Fix GBK decode crashes on Windows by forcing UTF-8 everywhere - #453
Fix GBK decode crashes on Windows by forcing UTF-8 everywhere#453Holmescalvin wants to merge 1 commit into
Conversation
subprocess.run(text=True) and Path.read_text()/write_text() without an explicit encoding fall back to the OS default, which is GBK on Chinese Windows. Reading/writing the project's UTF-8 files (or subprocess output containing non-ASCII bytes) then crashes with UnicodeDecodeError. Force encoding="utf-8" everywhere, with errors="replace" on subprocess capture so unexpected bytes degrade gracefully instead of killing the process.
934b526 to
581241c
Compare
|
Thanks for the detailed report and the Windows testing. |
Summary
subprocess.run(text=True)andPath.read_text()/write_text()without an explicitencodingfall back to the OS default codec, which is GBK on Chinese Windows.UnicodeDecodeError— e.g. runnings10_system_prompt/code.pyand readingREADME.mdfails immediately.encoding="utf-8"on everyread_text/write_textcall, and addsencoding="utf-8", errors="replace"to everysubprocess.run(..., text=True, ...)call across the tutorialcode.pyfiles,agents/*.py, and theagent-builderskill scripts, so output stays readable instead of crashing the process even if a command emits unexpected bytes.Test plan
python -m py_compileon every changed file — all compile cleanlys10_system_prompt/code.pyend-to-end on Windows (Chinese locale/GBK) after the fix — starts and readsREADME.md/memory files without crashingUnicodeDecodeError/TypeError: unsupported operand type(s) for +: 'NoneType' and 'str') to confirm root cause🤖 Generated with Claude Code