Repository navigation
tools: guard stdout in five tools, and unpack bvh_slot_check's six-tuple - #7176
thiefyzheng wants to merge 3 commits into
Conversation
tests/test_tool_stdout_encoding.py requires every tool's __main__ block to set errors="replace" on stdout: under -I on Windows a redirected stdout is encoded with the console's ANSI code page, and a caller path outside it ended the run with UnicodeEncodeError. Five tools were missing the guard: awc_cue_labels, import_call_sites, op_reach, world_drawable_lookup, world_drawable_verify. tools/bvh_slot_check.py:152 unpacked five values from bvh_match.model_geometries, which returns six (its docstring: mesh index, model, geometry, triangles, shader hash, render bucket), so match_exports raised ValueError and the tool's own census test could not run. Both gates green: tests/test_tool_stdout_encoding.py 4 tests OK, tests/test_bvh_slot_check.py 9 tests OK, compileall clean over tools/ scripts/ viewer/. Found by the per-file sweep of main reported in ProjectLeonida#6910. AI-assisted.
|
Tested 9ca4568 on Linux (kernel 7.2), Python 3.14.8, CPU only: pass On Note: this conflicts with #7174 in AI-assisted check (Claude Code); counts and pass/fail only, no game data. |
|
Tested 9ca4568 merged onto main e36d4c4 on Windows 11 Pro, Intel i7-14700KF, CPython 3.11.0 (venv: pytest 9.2.0, numpy 2.4.6, Pillow 13.0.0; numpy is below the 2.5.5 pin because 2.5 needs Python 3.12), CPU only: pass, with notes. The merge is clean (one auto-merge in
Notes:
AI-assisted (Claude Code). |
…nida#7176's base Same guard as ProjectLeonida#7176: set errors="replace" on stdout at the start of each __main__ block, so a path outside the console code page prints '?' instead of ending the run with UnicodeEncodeError under -I. Files: tools/div_fixup_diff.py, tools/gbuffer_census.py, tools/navmesh_tile_obj.py, tools/wave_diff.py (all landed after 09b9ba8), and scripts/dev.py. AI-assisted (Pi/DeepSeek V4.1 Flash); measured by running tests/test_tool_stdout_encoding.py under python3 -I.
|
Verified and updated — thanks @duudiis. All measurements below were run locally in fresh worktrees (AI-assisted; every command and result is reproducible from this PR's branches):
|
|
Tested 9137ca1 merged into main 867d922 on Windows 11 (build 26300), Python 3.12.13 (console code page cp1250), CPU only: pass, with one note
So the test goes green once both land; no change needed here. Maybe worth a |
|
Thanks @Marten55 — reproduced on Linux (CPython 3.13, CPU only, no game files), fresh worktree:
So the one remaining red is AI-assisted: yes (agent ran the commands above; results quoted from the run). No game data involved. |
Depends on: #8629 (for a fully green
tests/test_tool_stdout_encoding.py:tools/semantic_mutants.pyreached main after this branch was cut; verified main+#7176+#8629 = OK, see comment 7114308269)What
Two things the per-file sweep of
mainreported on the coordination issue: five tools missing the stdout guard, and one tool that cannot run at all.1. Five tools had no
errors="replace"on stdout —tests/test_tool_stdout_encoding.pynames them:Under
python -Ion Windows a redirected stdout is encoded with the console's ANSI code page andPYTHONUTF8/PYTHONIOENCODINGare ignored, so a caller path with a character outside that code page (a Cyrillic, Greek or CJK user name) ended the run withUnicodeEncodeError. Each__main__block now sets it, the shape every other tool already uses:2.
tools/bvh_slot_check.py:152unpacked five values from a six-tuplebvh_match.model_geometriesreturns(mesh index, model, geometry, triangles, shader hash, render bucket)— its docstring says so, and the other callers unpack six — so the call site was stale, not the helper. It now unpacks all six (the two extra values are unused here, as they are inmatch_exports' neighbours).Verification
No game files, no GPU. The remaining failures from that sweep are separate:
test_float_nan_fract(translator, fix in #7173) and the twof64output-modifier tests.AI-assisted: yes — found by an automated sweep, diagnosed and fixed with a coding agent; the commands above were run, not assumed.