Skip to content

semantic_mutants: guard stdout like every other tool (the test_tool_stdout_encoding entry no open PR covers) - #8629

Open
ne1i wants to merge 1 commit into
ItsNotRexed:mainfrom
ne1i:semantic-mutants-guard-stdout
Open

ne1i wants to merge 1 commit into
ItsNotRexed:mainfrom
ne1i:semantic-mutants-guard-stdout

Conversation

@ne1i

@ne1i ne1i commented Nov 23, 2026 •

Copy link
Copy Markdown

tests/test_tool_stdout_encoding.py requires every tool's if __name__ == "__main__": block to reconfigure stdout with errors="replace", so that a name the console code page cannot encode prints as ? instead of ending the run in UnicodeEncodeError. On main it lists eleven files without the guard. The open PRs for that test (#7589 + #7650, or #8094) cover ten of them and each leaves exactly one: tools/semantic_mutants.py. So this is the one entry no other open PR covers, not the last unguarded tool on main.

This adds the same guard there, in the form those PRs use, and nothing else (+4 lines).

What this does and does not do, plainly:

Tested on Linux, CPython 3.14, CPU only: python -I tests/test_semantic_mutants.py OK; compileall, check_no_game_data.py and git diff --check clean. No new test: the existing repository-wide test is the check.

Claim: #8504.

AI-assisted (DeepSeek V4.1 Flash wrote it; checked and re-run with Claude Code).

@Grimkeh Grimkeh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Linux CPU review (84360e9c)

What changed: semantic_mutants reconfigures stdout with errors="replace" like the other tools, so a redirected strict ANSI code page under -I does not crash on non-ASCII.

Checked:

  • Diff is the standard stdout guard; module parses cleanly.

Looks correct; no game files.

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 84360e9 on Windows 11 CPU (CPython 3.12.10, clean-room synthetic fixtures only, zero game data): pass.

Test Suite Execution & Verification

  • python -I tests/test_semantic_mutants.py: 8/8 passed in 83.43s.
  • python -I tests/test_tool_stdout_encoding.py EveryToolGuardsStdout.test_every_main_block_reconfigures_stdout:
    • Verified ools/semantic_mutants.py is removed from the unguarded missing list.
  • --help check: python -I tools/semantic_mutants.py --help exits 0 with standard usage.

Negative Control

Reverted ools/semantic_mutants.py to origin/main (867d922) while running EveryToolGuardsStdout.test_every_main_block_reconfigures_stdout:

  • Reproduced ools/semantic_mutants.py appearing in the missing unconfigured tools list (12 items total).
  • With 84360e9 applied, it is properly guarded and absent from the missing list.

Clean-Room & Repository Hygiene

  • python -I scripts/check_no_game_data.py tools/semantic_mutants.py: clean (0 violations).
  • git diff --check origin/main: clean (0 formatting or whitespace issues).
  • python -m compileall -q tools/semantic_mutants.py: clean.

LGTM!

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified on Windows 11 x64 (Python 3.14.0rc2, CPU-only; pure synthetic fixtures, zero game data).

Head verification

On HEAD (84360e9ceb772f0208ecbdb94c3e9ee9a3c3949f):

  • tools/semantic_mutants.py --help: runs cleanly with exit code 0.
  • test_tool_stdout_encoding.py: confirmed tools/semantic_mutants.py is no longer in the list of programs missing sys.stdout.reconfigure(errors="replace").
  • tests/test_semantic_mutants.py: 8/8 passed.

Negative control (discrimination check)

Restoring tools/semantic_mutants.py to HEAD~1:

  • tools/semantic_mutants.py is flagged as missing the stdout replacement guard by test_every_main_block_reconfigures_stdout.
  • Restoring 84360e9c satisfies the guard check.

Repository hygiene

  • python -I scripts/check_no_game_data.py tools/semantic_mutants.py: clean.
  • python -m compileall -q tools/semantic_mutants.py: clean.
  • git diff --check HEAD~1: clean (strict LF line endings, no trailing whitespace).

LGTM!

AI-assisted: verified and reviewed on Windows 11 environment.

@aslan2142

Copy link
Copy Markdown
Contributor

Tested 84360e9 merged onto main 867d922 (the head already contains that main, so the merge is a fast-forward).

Machine: Linux, Ryzen 9 7950X3D. No GPU was used.

The guard is correct and matches the other tools. semantic_mutants.py is fixed, but it is not the last unguarded program, as the title says.

Result:

  • python -I tests/test_tool_stdout_encoding.py: on main, test_every_main_block_reconfigures_stdout lists 12 programs without the guard. On this head it lists 11, and tools/semantic_mutants.py is no longer among them. The test still fails on both. The other 3 tests pass on both.
  • python -I tests/test_semantic_mutants.py: 8 tests OK.
  • The 4 added lines are the same as the guard the test looks for (sys.stdout.reconfigure(errors="replace") within 400 characters of if __name__ == "__main__":).

Notes:

  • The title says "the last test_tool_stdout_encoding entry". On today's main these programs also miss the guard: scripts/dev.py, tools/awc_cue_labels.py, tools/bvh_slot_check.py, tools/div_fixup_diff.py, tools/gbuffer_census.py, tools/import_call_sites.py, tools/navmesh_tile_obj.py, tools/op_reach.py, tools/wave_diff.py, tools/world_drawable_lookup.py, tools/world_drawable_verify.py. Some of them may have open pull requests of their own. The title could say "one of the remaining entries".
  • No defects in the diff.

AI-assisted (Claude Code, Claude Opus 5.5).

@ne1i ne1i changed the title semantic_mutants: guard stdout like every other tool (the last test_tool_stdout_encoding entry) semantic_mutants: guard stdout like every other tool (the test_tool_stdout_encoding entry no open PR covers) Nov 23, 2026
@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown
Author

Thanks, you are right about the title: on its own this removes one entry and the test stays red for the other eleven. What I meant, and should have written, is that it is the one entry no other open PR covers (#8094, or #7589 + #7650, guard the rest). I have changed the title and the first paragraph of the body to say that.

@Pierrot1398

Copy link
Copy Markdown

Tested 84360e9 on Windows 11 Pro (26300), Python 3.15.2, CPU only: pass.

On main 5d74c27, tests/test_tool_stdout_encoding.py lists 12 programs. With this PR merged together with #7174, #7650, #6508, #7152, #9070 and #7032 (no conflicts), the test passes. I didn't measure each PR alone.

AI-assisted (Claude Code).

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.

6 participants