Skip to content

tools: guard stdout in the 11 tools test_tool_stdout_encoding lists - #7816

Closed
Friendships6666 wants to merge 1 commit into
ProjectLeonida:mainfrom
Friendships6666:guard-stdout-in-the-11-listed-tools
Closed

Friendships6666 wants to merge 1 commit into
ProjectLeonida:mainfrom
Friendships6666:guard-stdout-in-the-11-listed-tools

Conversation

@Friendships6666

Copy link
Copy Markdown
Contributor

Leaving eleven tools without the stdout guard is what keeps test_tool_stdout_encoding red, and the guide in #7694 leaves them open: #7650 was titled for div_fixup_diff, gbuffer_census and navmesh_tile_obj but only patches the first, #7184 covers op_reach alone, and #7174 (which does cover wave_diff and scripts/dev.py) no longer applies because it also patches op_reach, which #7184 changes.

python -I ignores PYTHONUTF8 and PYTHONIOENCODING (#1406), so a redirected stdout is encoded with the console's ANSI code page and a caller path with a character outside it ends the run in UnicodeEncodeError. Every other tool already sets errors="replace" in its __main__ block, with the same comment; these eleven simply never got it. awc_cue_labels had no import sys at all, so it needed the import before the guard.

Overlap

tools/div_fixup_diff.py and tools/op_reach.py are also in #7650 and #7184. Mine is deliberately the other nine, so this merges after those two without a conflict; if either of them is closed instead, add its file here and the test still closes. Same for wave_diff.py against #7188, which is a different line in the same file and also merges either way.

Test

python -I tests/test_tool_stdout_encoding.py is green with this and its list is empty; it is red on main with the eleven paths. python -m compileall -q make_game.py tools tests is clean and python -I <tool> --help returns 0 for all eleven. Measured over the suite: 14 red standalone files before, 11 after, nothing green turned red.

Linux, Python 3.14.8 (3.12 path read, no version-specific code), no GPU, no game files.

`python -I` ignores PYTHONUTF8 and PYTHONIOENCODING (ItsNotRexed#1406), so a redirected stdout is encoded with the
console's ANSI code page and a caller path with a character outside it ended the run in UnicodeEncodeError.
Every other tool already sets errors="replace" in its __main__ block, with the same comment; these eleven
never got it: awc_cue_labels, bvh_slot_check, div_fixup_diff, gbuffer_census, import_call_sites,
navmesh_tile_obj, op_reach, wave_diff, world_drawable_lookup, world_drawable_verify and scripts/dev.py.
awc_cue_labels had no `import sys` at all, so it needed the import before the guard.

test_tool_stdout_encoding is green after this and its list is empty.

ItsNotRexed#7650 (div_fixup_diff), ItsNotRexed#7184 (op_reach) and ItsNotRexed#7174 (op_reach, wave_diff, dev.py) are open on parts of the same
files; this is the remainder they leave.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Possible duplicate: #7176 makes the same change to the same eleven files (scripts/dev.py and ten tools under tools/).

AI-assisted (Claude Code).

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 2f5f8beb on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main dde82f27: pass

  • python -I tests/test_tool_stdout_encoding.py: 4 tests OK (red on main: 1 failure listing 11 tools).
  • With only the non-test files reverted to main: 1 failure again.
  • compileall (where the change has Python files) and scripts/check_no_game_data.py on the changed files: clean.

Of the open PRs for this test that I ran (#7174, #7650), this is the only one that turns the file green on its own.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047.

@Friendships6666

Copy link
Copy Markdown
Contributor Author

Thanks, Jadiac5, for identifying the overlap, and thanks, ne1i, for running the independent checks. I compared the diffs: #7176 already covers all eleven stdout guards, and the additional LF change in this branch is covered by #7819 and #7857. Sorry for the duplication. I’m closing this PR so that review can continue on the earlier work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants