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

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

@⁠fin-github on GitHub · 2026-11-24 21:52 UTC · original
fin-github:codex/draft-114 → main · +59 −0 · 2 files · 1 commits · open

Claimed in the coordination issue as: DRAFT-114 (#14)

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.
**@⁠fin-github** on GitHub · 2026-11-24 21:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1324) `fin-github:codex/draft-114` → `main` · +59 −0 · 2 files · 1 commits · open Claimed in the coordination issue as: DRAFT-114 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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.
main()'s catch-all calls traceback.print_exc(), but the module never imported traceback. Any
exception a handler did not anticipate therefore raised NameError inside the except block, which
escaped main() and made Python exit 1: the code that means "the run completed and found a
mismatch". A calling script could not tell a crash from differing pixels.

tests/test_conformance_compare_crash.py makes a handler raise and checks both main()'s return
value and the exit status of the script (2, with the traceback and the "bug in compare.py" line,
and no NameError).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 9aece26a3e)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:47:28 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-24 23:40 UTC · original

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

**@⁠whoalin1** on GitHub · 2026-11-24 23:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1324#issuecomment-7147670128) 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).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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