Repository navigation
make_game: a redirected console must not kill --find on an un-encodable path - #1406
Conversation
…le path Windows encodes a redirected stdout (make_game.py > build.log) with the console's ANSI code page, and `python -I` ignores PYTHONUTF8, so when a found dump's path holds a character outside that code page (a Cyrillic, Greek or CJK user name in the profile it sits under), print() raised UnicodeEncodeError and --find / auto-discovery ended in a traceback. stderr escapes such characters (backslashreplace); stdout was strict. cli() now reconfigures stdout with errors="replace", so the listing prints '?' where the code page has no glyph. Interactive consoles already write Unicode and are unaffected. The regression test runs the real `make_game.py --find` as a child process over a synthetic dump (empty probe files with the manifest sizes, no game data) under a private-use character no ANSI code page maps: fails before the fix on every Windows locale, passes after, and passes on UTF-8 systems either way.
a0b3dc3 to
302f925
Compare
|
Independent CPU verification, at head
The console encoding fix is pinned by the new test and looks correct from the CPU side. |
|
Tested
No game files. |
|
CI note: the one red job here (Runtime / |
…l's output On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with UnicodeEncodeError as soon as a tool printed it. ItsNotRexed#1406 fixed make_game.py; every CLI tool in tools/ now starts its __main__ block the same way (stdout errors="replace"). tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes (analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested on Linux (WSL2 Ubuntu), Python 3.12, CPU only: pass. |
|
Tested 302f925 on Windows 11 Home 10.0.26300 with ANSI code page 1252, the case this PR is about. Python 3.14.7, pytest 9.2.0.
The new test fails without the change, so it covers it. #1428 changes how many tools write to a redirected console on Windows, and #1426 does the same for AI-assisted (Claude Code). No game files. |
The ItsNotRexed#1406 guard every tool's __main__ block carries: under python -I a redirected stdout uses the console code page, and a path with characters outside it must not end the run in UnicodeEncodeError. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Claimed in #1380 (comment 7078198600): new BUILD item.
What was wrong
On Windows,
python -IignoresPYTHONUTF8, and a redirected stdout (python -I make_game.py > build.log, or any pipe) is encoded with the console's ANSI code page (cp1252 here), strictly.--findand the no---gameauto-discovery print every found dump's path to stdout, so a dump under a path with a character outside the code page — a Cyrillic, Greek or CJK user name in the profile it sits under — ended the listing with aUnicodeEncodeErrortraceback (exit 1, nothing listed). stderr already escapes such characters (backslashreplace); stdout did not. On Linux (UTF-8) the same command works, so CI never saw it.Repro before the fix (Windows 11, cp1252, commit f85582e):
The fix
cli()reconfiguressys.stdoutwitherrors="replace"beforemain(): a redirected console now prints?where the code page has no glyph, and the listing completes. Interactive consoles already write Unicode and are unaffected; on POSIX this only changes streams that would have crashed anyway.Test
tests/test_make_game_platform.py::RedirectedConsoleEncodingTestruns the realmake_game.py --findas a child process (no mocks): a fake profile contains a synthetic dump — three empty files truncated to the manifest's probe sizes, somatch_version()matches on name/size only, no game data — under a folder named with a private-use character (U+E9C3) that no ANSI code page maps, so the failure reproduces on every Windows locale, not just cp1252.FAILED (failures=1)— child exits 1 withUnicodeEncodeError.tests/test_make_game_platform.py; the child exits 0 and lists the dump.Tested
python -I tests/test_make_game_platform.py(33 OK), all 11tests/test_make_game_*suites OK,python -m compileall -q make_game.py tools tests,python -I make_game.py --help,python -I make_game.py --findon this PC. No GPU, no game files involved.AI-assisted (omp orchestrator).