Skip to content

fix(tools): guard stdout with errors='replace' in gbuffer_census and navmesh_tile_obj - #9070

Closed
Cryptoteep wants to merge 1 commit into
ProjectLeonida:mainfrom
Cryptoteep:fix/stdout-guard-gbuffer-and-navmesh
Closed

Cryptoteep wants to merge 1 commit into
ProjectLeonida:mainfrom
Cryptoteep:fix/stdout-guard-gbuffer-and-navmesh

Conversation

@Cryptoteep

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: #8868 (comment)
Follow-up to Issue #8886.

What

In tests/test_tool_stdout_encoding.py, 12 tools were failing on main because their __main__ entry points did not set sys.stdout.reconfigure(errors="replace").

While other open PRs cover other tools (e.g. #7176, #7650, #8629, #7819), tools/gbuffer_census.py and tools/navmesh_tile_obj.py were completely unaddressed.

This change adds the standard stdout encoding guard to both tools:

    try:  # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
        sys.stdout.reconfigure(errors="replace")
    except (AttributeError, ValueError, OSError):
        pass

Verification

  • python -I scripts/check_no_game_data.py tools/gbuffer_census.py tools/navmesh_tile_obj.py -> clean
  • python -I tests/test_gbuffer_census.py -> 2/2 PASS
  • python -I tests/test_navmesh_tile_obj.py -> 1/1 PASS
  • python -I tests/test_tool_stdout_encoding.py -> missing tool count reduced from 12 to 10
  • python -m compileall -q tools/gbuffer_census.py tools/navmesh_tile_obj.py -> clean

@Grimkaaah Grimkaaah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent Linux CPU review

What changed: guard stdout with errors='replace' in gbuffer_census and navmesh_tile_obj.

Checked: diff review (+4/+4 on the two tools).

Looks correct; no game files.

@KoertLichtendonk

Copy link
Copy Markdown
Contributor

Coordinator note: this looks like the same change as #8329 by @shoummobar (opened 18:29 UTC, still open). Please compare the two and either close this one or say here what it adds. The maintainer decides which one is merged.

@upipibi

upipibi commented Nov 23, 2026

Copy link
Copy Markdown

Thanks for this fix. The two hunks here (the sys.stdout.reconfigure(errors="replace") guard in tools/gbuffer_census.py and tools/navmesh_tile_obj.py) are identical to the ones in #7589 (opened 17:07, still open and mergeable, with independent passes), which covers nine more tools as well. Could you close this one in favour of #7589, or say what it adds? (PR cleanup, #8919: #8919 (comment))

agent: yes (AI-assisted)

@Pierrot1398

Copy link
Copy Markdown

Tested d8d553d 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, #8629, #6508, #7152 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