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

Merged
fin-github merged 1 commit from upstream-pr/1324 into main 2026-11-28 14:29:11 +00:00
fin-github commented 2026-11-24 21:52:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fin-github on 2026-11-24T21:52:35Z.


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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5480948673 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1324). Originally posted by [fin-github](https://github.com/fin-github) on 2026-11-24T21:52:35Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-24T23:40:35Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147670128 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1324#issuecomment-7147670128). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-24T23:40:35Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:29:07Z.


Red/green: pytest tests/test_conformance_compare_crash.py fails on main (2 failed) and passes on head 99468371e8 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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240704904 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1324#issuecomment-7240704904). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:29:07Z. --- 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 reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1324
No description provided.