pr_conflict_label: guard stdout against the console code page (TEST-WIN-SWEEP) #367

Open
github-bot wants to merge 1 commit from github-bot/gh-367 into main AGit
Owner

@⁠ItsMrDubey on GitHub · 2026-11-24 03:56 UTC · original
ItsMrDubey:win-stdout-pr-conflict-label → main · +4 −0 · 1 files · 1 commits · open

Claimed in the coordination issue as: TEST-WIN-SWEEP (#14)

What and why

python -I tests/test_tool_stdout_encoding.py fails on main: test_every_main_block_reconfigures_stdout lists tools/pr_conflict_label.py, added in 4f7a347 (PR-CONFLICT-LABEL) without the sys.stdout.reconfigure(errors="replace") guard every other program's __main__ block has. Under -I a redirected stdout on Windows is strict cp1252, so a character outside the code page would end the run with UnicodeEncodeError. The check itself is not Windows-specific, so the test fails on every OS; the sweep found it on Windows.

The __main__ block now sets the same guard, in the same words, as scripts/ci_expected_failures.py and the tools.

Tested

Windows 11, Python 3.11.9 and 3.12.9:

  • python -I tests/test_tool_stdout_encoding.py: before FAIL ... ['tools/pr_conflict_label.py'] != [] (exit 1); after OK.
  • python -I tests/test_pr_conflict_label.py: OK.
  • python -I scripts/check_no_game_data.py tools/pr_conflict_label.py: clean.
  • Linux (the conflict-label workflow runs python3 -I tools/pr_conflict_label.py): reconfigure is a no-op there for a UTF-8 stdout and the guard swallows the errors it could raise.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. n/a: no translator rule
**@⁠ItsMrDubey** on GitHub · 2026-11-24 03:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/367) `ItsMrDubey:win-stdout-pr-conflict-label` → `main` · +4 −0 · 1 files · 1 commits · open Claimed in the coordination issue as: TEST-WIN-SWEEP (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why `python -I tests/test_tool_stdout_encoding.py` fails on main: `test_every_main_block_reconfigures_stdout` lists `tools/pr_conflict_label.py`, added in 4f7a347 (PR-CONFLICT-LABEL) without the `sys.stdout.reconfigure(errors="replace")` guard every other program's `__main__` block has. Under `-I` a redirected stdout on Windows is strict cp1252, so a character outside the code page would end the run with `UnicodeEncodeError`. The check itself is not Windows-specific, so the test fails on every OS; the sweep found it on Windows. The `__main__` block now sets the same guard, in the same words, as `scripts/ci_expected_failures.py` and the tools. ### Tested Windows 11, Python 3.11.9 and 3.12.9: - `python -I tests/test_tool_stdout_encoding.py`: before `FAIL ... ['tools/pr_conflict_label.py'] != []` (exit 1); after OK. - `python -I tests/test_pr_conflict_label.py`: OK. - `python -I scripts/check_no_game_data.py tools/pr_conflict_label.py`: clean. - Linux (the conflict-label workflow runs `python3 -I tools/pr_conflict_label.py`): `reconfigure` is a no-op there for a UTF-8 stdout and the guard swallows the errors it could raise. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. n/a: no translator rule
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:55:57 +00:00
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-24 08:28 UTC · original

Tested 9683501d (cherry-picked onto main 1c93c869) on native Windows 11 Home (build 26300), Python 3.12.10: pass.

On main 1c93c869, python -I tests/test_tool_stdout_encoding.py fails test_every_main_block_reconfigures_stdout here, naming tools/pr_conflict_label.py as the one program without the guard. With this commit the file ends in OK. python -m compileall -q make_game.py tools tests: exit 0. No game files.

Not run: pr_conflict_label.py itself against a console code page.

AI-assisted (Claude Code ran the tests and wrote this comment).

**@⁠quartz-heron-58** on GitHub · 2026-11-24 08:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/367#issuecomment-7126175382) Tested 9683501d (cherry-picked onto main 1c93c869) on native Windows 11 Home (build 26300), Python 3.12.10: pass. On main 1c93c869, `python -I tests/test_tool_stdout_encoding.py` fails `test_every_main_block_reconfigures_stdout` here, naming `tools/pr_conflict_label.py` as the one program without the guard. With this commit the file ends in OK. `python -m compileall -q make_game.py tools tests`: exit 0. No game files. Not run: `pr_conflict_label.py` itself against a console code page. AI-assisted (Claude Code ran the tests and wrote this comment).
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-24 09:52 UTC · original

Tested here, not only read. At 7430f59b2 python3 -I tests/test_tool_stdout_encoding.py is still red and names exactly one program, tools/pr_conflict_label.py, merged without the guard in 4f7a34777 - the same class as d083a2cc3's note "the 15 programs merged without the stdout guard got the same block as the others", so the resolution is the block, never the test's expectation.
Your 4-line guard turns it green at your head 9683501d0 (Ran 4 tests ... OK) and is behaviour-neutral: tests/test_pr_conflict_label.py gives 12 OK with and without it. Everything else I ran at your head and on the rebased copy is OK: test_text_write_line_endings (3), test_bad_input_errors (11), test_docs_encoding, test_text_encoding; python3 -m compileall -q make_game.py tools tests scripts viewer exit 0; git diff --check clean; python3 -I scripts/check_no_game_data.py tools/pr_conflict_label.py exit 0.
Your base is about 30 commits behind, so here is the identical guard applied cleanly to d42773d07 / 7430f59b2 - 483 bytes, 1 file changed, 4 insertions - for whoever rebases:

--- a/tools/pr_conflict_label.py
+++ b/tools/pr_conflict_label.py
@@ if __name__ == "__main__":
+    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
     sys.exit(main())

AI-assisted (Hermes agent on behalf of @⁠Headache3318); Arch Linux, 8-core x86-64, python 3.14.9, no game files, no GPU run. The Windows code-page failure itself is not measured on this box - the -X utf8=0 runs reproduce the convention the test enforces, not the console behaviour.

**@⁠Headache3318** on GitHub · 2026-11-24 09:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/367#issuecomment-7128015151) Tested here, not only read. At `7430f59b2` `python3 -I tests/test_tool_stdout_encoding.py` is still red and names exactly one program, `tools/pr_conflict_label.py`, merged without the guard in `4f7a34777` - the same class as `d083a2cc3`'s note "the 15 programs merged without the stdout guard got the same block as the others", so the resolution is the block, never the test's expectation. Your 4-line guard turns it green at your head `9683501d0` (`Ran 4 tests ... OK`) and is behaviour-neutral: `tests/test_pr_conflict_label.py` gives 12 OK with and without it. Everything else I ran at your head and on the rebased copy is OK: `test_text_write_line_endings` (3), `test_bad_input_errors` (11), `test_docs_encoding`, `test_text_encoding`; `python3 -m compileall -q make_game.py tools tests scripts viewer` exit 0; `git diff --check` clean; `python3 -I scripts/check_no_game_data.py tools/pr_conflict_label.py` exit 0. Your base is about 30 commits behind, so here is the identical guard applied cleanly to `d42773d07` / `7430f59b2` - 483 bytes, 1 file changed, 4 insertions - for whoever rebases: ```diff --- a/tools/pr_conflict_label.py +++ b/tools/pr_conflict_label.py @@ if __name__ == "__main__": + 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 sys.exit(main()) ``` **AI-assisted** (Hermes agent on behalf of @⁠Headache3318); Arch Linux, 8-core x86-64, python 3.14.9, no game files, no GPU run. The Windows code-page failure itself is not measured on this box - the `-X utf8=0` runs reproduce the convention the test enforces, not the console behaviour.
This pull request has changes conflicting with the target branch.
  • tools/pr_conflict_label.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/367/head:github-bot/gh-367'
git switch 'github-bot/gh-367'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-367'
git switch 'github-bot/gh-367'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-367'
git switch 'github-bot/gh-367'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-367'
git switch 'main'
git merge --squash 'github-bot/gh-367'
git switch 'main'
git merge --ff-only 'github-bot/gh-367'
git switch 'main'
git merge 'github-bot/gh-367'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.