tools/game_run_summary: guard stdout encoding, BOM ints, OSError and RecursionError #1837
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1837"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T12:57:08Z.
Claimed in the coordination issue as: GAME-RUN-SUMMARY-STDOUT-BOM-AND-VALIDATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163012307)
What and why
sys.stdout.reconfigure(errors="replace")guard intools/game_run_summary.py's__main__block so redirected Windowspython -Iruns do not raiseUnicodeEncodeErrorwhen reporting method names outside the ANSI/OEM code page.exit_codeandsecondsin_read_int()withencoding="utf-8-sig"so UTF-8 BOM-prefixed files parse cleanly instead of reading asNone.open()in_lines()againstOSErrorand catch(ValueError, RecursionError)onboot.jsonljson.loads()lines so deeply nested corrupt entries incrementstartup_bad_linescleanly.--limit-secondsvalues (< 1) inmain()viaparser.error(...)(exit2).tests/test_game_run_summary.py.Tested
python -I tests/test_game_run_summary.py -v->Ran 12 tests in 0.156s,OK.upstream/main(98c2f777) baseline worktree with updatedtests/test_game_run_summary.py->Ran 12 tests in 0.176s,FAILED (failures=4, errors=2)(all new regression checks fail before the fix).python -I tests/test_ci_registration.py->Ran 16 tests in 5.198s,OK.python -I tests/test_text_write_line_endings.py->Ran 3 tests in 12.859s,OK.python -I scripts/check_no_game_data.py tools/game_run_summary.py tests/test_game_run_summary.py-> exit0.python -I -m compileall -q tools/game_run_summary.py tests/test_game_run_summary.pyandgit diff --check-> exit0.GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)
AI-assisted: yes
Checklist
needs rebase).Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:50:20Z.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_game_run_summary.py:tools/game_run_summary.pyshould no longer appear intests/test_tool_stdout_encoding.py's list (it is one of the two tools still listed after #1673).(AI-assisted test run; output checked by hand.)
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T12:11:46Z.
Thanks @DeadlyChirp — checked current
main:tools/game_run_summary.pyis already removed fromNOT_YET_GUARDEDintests/test_tool_stdout_encoding.py, so#1837stays conflict-free without modifying that test file.Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:00:41Z.
Tested
e76cabc17merged (no commit) withmainaa918e5d9. Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.Blocker: it breaks once merged with current
main. On its own head,tests/test_game_run_summary.pypasses (12 tests). Merged withmain,test_utf8_bom_exit_code_and_seconds_are_parsedfails: it expectstime limit (60 s) reached, and the tool now saysprocess exit 124 (0x0000007c), no exit event in the startup trace.mainchanged how an exit 124 is reported since this branch, so the PR needs a rebase and either an updated expectation or an updated message.tools/game_run_summary.pyback tomain, 3 failures and 2 errors (e.g.None != 124). The rest of the new checks do fail without the fix.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T02:56:15Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
c8bf0e7b6, PR heade76cabc17: red 5 failures / green 1 failurepython3.12 -I tests/test_game_run_summary.py(12 tests):git merge-tree). main changed this test file since the PR base (#2028), so red = the merged test file against main's code.test_bad_arguments_fail(--limit-seconds 0and-5),test_utf8_bom_exit_code_and_seconds_are_parsed,test_deeply_nested_boot_jsonl_line_is_counted_as_bad,test_lines_handles_oserror_on_second_open.test_non_ascii_stdout_is_safe_under_redirected_ioalready passes on main (4b10cbe91addederrors="replace").git merge --no-ff): 11 OK, 1 failure:test_utf8_bom_exit_code_and_seconds_are_parsed—'time limit (60 s) reached' not found in 'process exit 124 (0x0000007c), no exit event…'.finished_before_limit). The test uses seconds=45 with limit=60, which main now treats as an early exit. Setting seconds to >= 60 in the test should fix it (ASSUMED).game_run_summary. Skipped: none.utf-8-sigin_read_int, the OSError guard in_lines, RecursionError and--limit-secondsvalidation look right; thereconfigureblock duplicates main's but only one remains after merge. No game data.Verdict: FAILS (needs a rebase on #2028 and the test's seconds value adjusted).
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:34:42Z.
Could you merge the current
maininto this branch? As noted in the verification above, after #2028maintells an early exit from a timeout (finished_before_limit), sotest_utf8_bom_exit_code_and_seconds_are_parsedfails on the merge withseconds=45/limit=60; using seconds >= 60 in that test should make it pass (ASSUMED). The rest of the PR looked good on macOS. If there is no reply in about 24 h, we may open a follow-up PR that carries your commits (with you as co-author) and links back here.AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T14:38:43Z.
Taken over in #2746 (no answer since the request above to merge
main). Your commite76cabc17is kept as is with you as author; #2746 adds only themainmerge and the test update after #2028 (seconds at the limit). If you come back to this one, say so and #2746 can be closed in favour of this PR.AI-assisted: Claude Code