Skip to content

Commit c5fe066

Browse files
TMHSDigitalclaude
andcommitted
docs(exit-pre-sidecar): correct a false catalog claim and document the falsifiers
The module docstring told readers the catalog's min_version was 5.0 and wrong. It has been 5.1 since the example's introducing commit, so the note was never true and sent anyone who read it to "fix" a correct catalog row. Re-verified the version claim against all three binaries: hasattr(bpy.app.handlers, "exit_pre") is False on 4.5.11 LTS and True on 5.1.2 and 5.2.1 LTS, and exit_pre is the only exit- or quit-related name in bpy.app.handlers on the versions that have it -- so there is no older spelling to fall back to. The documented behaviour is correct. README also now: - states the contract and why it matters (atexit is the bug class this catches), with the 4.5 and 5.2 bpy.app.handlers API links - explains that exiting 77 on 4.5 is correct by design, and what stops a skip from spreading: min_version 5.1, the runner failing a skip above the floor, and summarize.py reddening an all-skip job - enumerates the falsifiers in a table with what each breaks, its script exit and how the harness fails, and names --write-in-main and --atexit-instead as the two an existence-only check would pass, which is why the catalog row carries sidecar_contains Contract, assertions and exit codes unchanged. Verified before and after on 4.5.11, 5.1.2 and 5.2.1: default SKIP/PASS/PASS, all five harness falsifiers FAIL, --force-run exits 2 on 4.5, plain default exits 77. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com>
1 parent 7356ecb commit c5fe066

2 files changed

Lines changed: 70 additions & 11 deletions

File tree

‎examples/exit-pre-sidecar/README.md‎

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,69 @@ Witnesses [`drivers-and-app-handlers`](../../skills/drivers-and-app-handlers/SKI
55
`main` does not write the file. The host runner asserts it after the
66
process exits (`tests/smoke/run_example.py --expect-sidecar`).
77

8-
5.1+. 4.5 LTS: `AttributeError` — no `exit_pre`. Skip
9-
(`SMOKE_SKIP: exit_pre requires Blender 5.1+`, exit 77, catalog
10-
`min_version` 5.1). `--force-run` bypasses the skip so 4.5 fails
11-
accessing the handler list.
8+
No gallery still. There is no geometry: the witness is a file that does
9+
not exist until the process is already gone, and a render would look
10+
identical whether the handler fired or not.
1211

13-
No gallery still. There is no geometry.
12+
## The contract
1413

15-
The harness checks **contents** (`sidecar_contains=exit_pre-ok`), not
16-
existence only. A file written from `main` or `atexit` is red. Several
17-
falsifiers exit 0 from the script so the **harness** can fail after Blender
18-
dies.
14+
`exit_pre` is the only handler in `bpy.app.handlers` that runs during
15+
interpreter teardown, and it is the difference between a callback that
16+
runs and one that silently never does. Code that relies on `atexit` for
17+
this — saving a session log, flushing a render manifest, releasing a
18+
licence token — is the class of bug this example exists to catch.
19+
20+
| Blender | `hasattr(bpy.app.handlers, "exit_pre")` |
21+
| --- | --- |
22+
| 4.5.11 LTS | `False` — `AttributeError` on access |
23+
| 5.1.2 | `True` |
24+
| 5.2.1 LTS | `True` |
25+
26+
Re-verified 2026-09-22 against all three binaries. `exit_pre` is also
27+
the only exit- or quit-related name in `bpy.app.handlers` on the
28+
versions that have it, so there is no older spelling to fall back to.
29+
30+
API reference:
31+
[`bpy.app.handlers` (5.2 LTS)](https://docs.blender.org/api/current/bpy.app.handlers.html)
32+
·
33+
[`bpy.app.handlers` (4.5 LTS)](https://docs.blender.org/api/4.5/bpy.app.handlers.html)
34+
— the 4.5 page lists no `exit_pre`, which is the absence this example
35+
turns into a skip.
36+
37+
## Why 4.5 skips rather than fails
38+
39+
Exiting 77 on 4.5 is **correct by design**, not a gap in coverage. The
40+
handler does not exist there, so there is no contract to witness and no
41+
assertion that could meaningfully run. The catalog carries
42+
`min_version` 5.1 and the runner treats a skip above that floor as a
43+
FAIL, so the skip cannot quietly spread to a version that should run.
44+
`tests/smoke/summarize.py` makes a job red if *every* example skipped,
45+
so a repo-wide skip cannot pass either.
46+
47+
`--force-run` bypasses the skip so 4.5 proves the absence rather than
48+
assuming it: the run exits 2 on `AttributeError`, and also exits 2 if
49+
`exit_pre` turns out to exist on a version that should not have it.
50+
51+
## Falsifiers
52+
53+
The harness checks the sidecar's **contents**
54+
(`sidecar_contains=exit_pre-ok`), not merely that a file appeared.
55+
Most falsifiers therefore exit **0 from the script** — Blender reports
56+
success — and the **harness** fails afterwards, which is the only place
57+
a post-exit contract can be falsified.
58+
59+
| Flag | What it breaks | Script exit | Harness |
60+
| --- | --- | --- | --- |
61+
| `--no-handler` | nothing registered, nothing written | 0 | FAIL, no sidecar |
62+
| `--silent-handler` | `exit_pre` registered but writes nothing | 0 | FAIL, no sidecar |
63+
| `--wrong-text` | handler writes `nope` | 0 | FAIL, contents mismatch |
64+
| `--write-in-main` | `from-main` written in `main`, no handler | 0 | FAIL, contents mismatch |
65+
| `--atexit-instead` | `atexit` writes `atexit-ok` instead of `exit_pre` | 0 | FAIL, contents mismatch |
66+
| `--force-run` on 4.5 | asserts `exit_pre` is genuinely absent | 2 | n/a |
67+
68+
`--write-in-main` and `--atexit-instead` are the two that matter: both
69+
produce a file, so an existence-only check would pass them. They are why
70+
the catalog row carries `sidecar_contains`.
1971

2072
## Run
2173

@@ -28,6 +80,8 @@ python tests/smoke/run_example.py --name exit-pre-sidecar \
2880
--expect-sidecar /tmp/exit-pre.sidecar --sidecar-contains exit_pre-ok
2981
```
3082

83+
Append `-- --wrong-text` (or any flag above) to falsify.
84+
3185
## Exit codes
3286

3387
Per-script sequential checks. `9` is a valid check code; there is no rule

‎examples/exit-pre-sidecar/exit_pre_sidecar.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
handler writes it. The host runner (``tests/smoke/run_example.py``)
77
asserts the file after the process exits.
88
9-
5.1+. 4.5 LTS has no ``exit_pre`` (AttributeError). Catalog
10-
``min_version`` 5.0 is wrong — the floor is 5.1. Skip: ``SMOKE_SKIP``.
9+
5.1+. 4.5 LTS has no ``exit_pre`` (AttributeError), so the catalog
10+
``min_version`` is 5.1 and the script skips below it (``SMOKE_SKIP``).
1111
``--force-run`` bypasses the skip so 4.5 fails accessing ``exit_pre``.
1212
13+
Re-verified 2026-09-22 on 4.5.11 LTS, 5.1.2 and 5.2.1 LTS:
14+
``hasattr(bpy.app.handlers, "exit_pre")`` is False / True / True, and
15+
``exit_pre`` is the only exit-related name in ``bpy.app.handlers`` on
16+
the versions that have it.
17+
1318
No gallery still. There is no geometry.
1419
1520
blender --background --python exit_pre_sidecar.py --

0 commit comments

Comments
 (0)