Repository navigation
gbuffer_census, navmesh_tile_obj: guard stdout with errors='replace' - #7983
Friendships6666 wants to merge 1 commit into
Conversation
Both print a caller path that the console code page may not have: gbuffer_census its input, navmesh_tile_obj its --out. Under a redirected stdout and `python -I` that is a strict UnicodeEncodeError on Windows, so a Polish, Greek or CJK user name ended the run. Same guard, wording and placement as the tools already converted, and the last two entries of the test_tool_stdout_encoding list that no open pull request covers.
|
checked: #7983 | with: python -I tests/test_tool_stdout_encoding.py | on: Windows 11, CPython 3.13, head f41d426, CPU only | result: the two files this PR touches (gbuffer_census.py, navmesh_tile_obj.py) now carry the |
|
Tested
AI-assisted (Claude Code). |
|
Correction to my review above: I said none of #7816, #7650 and #7174 touches these two files. That was wrong. #7816 ("guard stdout in the 11 tools test_tool_stdout_encoding lists") already changes both AI-assisted (Claude Code). |
Claim: #7694 (comment)
Depends on: none (the other nine entries of the list are separate pull requests; the list only turns fully green when all of them land)
What and why
tests/test_tool_stdout_encoding.pylists 11 programs whose__main__block doesn't seterrors="replace"on stdout. Nine of them already have an open pull request (#7032, #6508, #7152, #7184, #7174, #7650). These two were the rest:tools/gbuffer_census.py:145— prints the input paths it censusedtools/navmesh_tile_obj.py:75— prints the--outpath it wroteOn Windows a redirected stdout is encoded with the console's ANSI code page, and
python -IignoresPYTHONUTF8/PYTHONIOENCODING, so either path with a character the code page lacks ended the run inUnicodeEncodeError.The fix
The same four lines the converted tools use, in the same place and with the same comment:
AttributeErrorcovers a stdout withoutreconfigure(a captured StringIO in a test),ValueErrora closed one,OSErrora detached console.Tested
Linux, Python 3.14.8, no game files.
python3 -m pytest -q tests/test_tool_stdout_encoding.py→ 3 passed, 2 subtests passed, 1 failed; the remaining failure is the whole-tree scan, whose list dropped from 11 to 9 entries and no longer names either filepython3 -I -X utf8=0 tests/test_tool_stdout_encoding.py→ same resultpython3 -I tools/gbuffer_census.py --helpandpython3 -I tools/navmesh_tile_obj.py --help→ exit 0compileallandgit diff --checkclean