conformance: preserve traceback and exit 2 for unexpected exceptions (DRAFT-114) #1324

Merged
leonida/mandy
fin-github merged 1 commit from codex/draft-114 into main 2026-11-28 14:29:11 +00:00

Pull request successfully merged and closed

fin-github commented 2026-11-24 21:52:35 +00:00

Claimed in the coordination issue as: DRAFT-114 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145478287)

What and why

Supersedes carried-over draft #114. David's original commit from old-pr/9848 was cherry-picked with -x onto main at 4a50cafc7.

compare.py now imports traceback so an unexpected command-handler exception prints the original exception and exits 2. Exit 1 remains the pixel mismatch status. The missing import had raised a second exception inside the error handler and caused Python to exit 1.

Tested

On baseline 4a50cafc7, the direct test raised NameError and the subprocess test returned 1. Reproduced in PowerShell with:

git show 9aece26a3:tests/test_conformance_compare_crash.py | python -I -c "exec(compile(__import__('sys').stdin.read(), __file__ := 'tests/test_conformance_compare_crash.py', 'exec'))"

Both crash regressions, all four PNG transparency tests and all 22 comparison selftest checks passed. Touched-file compilation, changed-file game-data and whitespace checks passed. The merge simulation with #1322 was clean.

python -I tests/test_conformance_compare_crash.py
python -I tests/test_conformance_png_transparency.py
python -I tools/conformance/compare.py selftest
$changed = git diff --name-only upstream/main...HEAD
python -m compileall -q @changed
python -I scripts/check_no_game_data.py @changed
git diff --check upstream/main...HEAD
git merge-tree --write-tree HEAD codex/draft-256

Windows 11 build 26200, Python 3.14.4, synthetic inputs only.

GPUs tested: n/a (CPU-only).

AI-assisted: original patch by Claude Code (Claude Opus 5.5), rebase and verification by Codex.

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
Claimed in the coordination issue as: DRAFT-114 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145478287) ### What and why Supersedes carried-over draft #114. David's original commit from `old-pr/9848` was cherry-picked with `-x` onto `main` at `4a50cafc7`. `compare.py` now imports `traceback` so an unexpected command-handler exception prints the original exception and exits 2. Exit 1 remains the pixel mismatch status. The missing import had raised a second exception inside the error handler and caused Python to exit 1. ### Tested On baseline `4a50cafc7`, the direct test raised `NameError` and the subprocess test returned 1. Reproduced in PowerShell with: ```powershell git show 9aece26a3:tests/test_conformance_compare_crash.py | python -I -c "exec(compile(__import__('sys').stdin.read(), __file__ := 'tests/test_conformance_compare_crash.py', 'exec'))" ``` Both crash regressions, all four PNG transparency tests and all 22 comparison selftest checks passed. Touched-file compilation, changed-file game-data and whitespace checks passed. The merge simulation with #1322 was clean. ```powershell python -I tests/test_conformance_compare_crash.py python -I tests/test_conformance_png_transparency.py python -I tools/conformance/compare.py selftest $changed = git diff --name-only upstream/main...HEAD python -m compileall -q @changed python -I scripts/check_no_game_data.py @changed git diff --check upstream/main...HEAD git merge-tree --write-tree HEAD codex/draft-256 ``` Windows 11 build 26200, Python 3.14.4, synthetic inputs only. GPUs tested: n/a (CPU-only). AI-assisted: original patch by Claude Code (Claude Opus 5.5), rebase and verification by Codex. ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption.
whoalin1 commented 2026-11-24 23:40:35 +00:00

Independent verification (overnight shift, CPU/tooling only, no game data).

Commands run on head 99468371 (Git Bash, py -3.14):

  • py -3.14 -m compileall -q tools/conformance/compare.py tests/test_conformance_compare_crash.py — clean
  • py -3.14 -I tests/test_conformance_compare_crash.py: Ran 2 tests, OK (covers both in-process exit code and the real CLI subprocess exit status)
  • py -3.14 -I tools/conformance/compare.py selftest: selftest passed

Confirmed the bug is real on the merge base: 4a50cafc7:tools/conformance/compare.py line 1867 calls traceback.print_exc() inside main()'s catch-all except Exception, but traceback is never imported — so an unexpected exception would itself raise NameError inside the handler and escape main(), which Python reports as exit 1, indistinguishable from a pixel mismatch. The one-line import traceback fixes exactly that; the new test's crash path now prints the traceback, the 'bug in compare.py, not a pixel mismatch' message, and returns EXIT_ERROR (2).

Verdict: verified, minimal correct fix.

AI-assisted verification (Devin).

Independent verification (overnight shift, CPU/tooling only, no game data). Commands run on head 99468371 (Git Bash, py -3.14): - `py -3.14 -m compileall -q tools/conformance/compare.py tests/test_conformance_compare_crash.py` — clean - `py -3.14 -I tests/test_conformance_compare_crash.py`: Ran 2 tests, OK (covers both in-process exit code and the real CLI subprocess exit status) - `py -3.14 -I tools/conformance/compare.py selftest`: selftest passed Confirmed the bug is real on the merge base: `4a50cafc7:tools/conformance/compare.py` line 1867 calls `traceback.print_exc()` inside `main()`'s catch-all `except Exception`, but `traceback` is never imported — so an unexpected exception would itself raise NameError inside the handler and escape `main()`, which Python reports as exit 1, indistinguishable from a pixel mismatch. The one-line `import traceback` fixes exactly that; the new test's crash path now prints the traceback, the 'bug in compare.py, not a pixel mismatch' message, and returns EXIT_ERROR (2). Verdict: verified, minimal correct fix. AI-assisted verification (Devin).
MoonEyes commented 2026-11-28 14:29:07 +00:00

Red/green: pytest tests/test_conformance_compare_crash.py fails on main (2 failed) and passes on head 99468371e8e5 merged with main (2 passed).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

Red/green: `pytest tests/test_conformance_compare_crash.py` fails on main (2 failed) and passes on head 99468371e8e5 merged with main (2 passed). Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No description provided.