A clean shutdown is an incomplete success signal. contextlib.ExitStack can close every owned resource while the exception state changes underneath that cleanup: an inner exit callback can suppress the body exception, replace it by raising another exception, or suppress a replacement raised by a still-deeper callback. An outer callback then receives the updated exception state rather than the one that originally left the body. The Python documentation explicitly describes reverse callback order and this updated-state behavior.
Executive summary. The release question is therefore not “did cleanup run?” It is: which callbacks ran, in what order, which exception object did each callback receive, what exception object escaped, and did that state match an independently authored expectation? For this playbook I pin the semantic baseline to CPython 3.13.5, released June 11, 2025, and the immutable CPython source tag v3.13.5. At the time of the reported run, the official Python 3.13 documentation showed the maintenance release 3.13.18, so the exact source tag is the stronger implementation pin.
I also executed the isolated standard-library-only fixture described below on CPython 3.13.5. The run observed LIFO cleanup, body-exception suppression, replacement-exception propagation, suppression of a replacement, the inability of ExitStack.callback() return values to suppress, and close() starting cleanup with no active exception. Those observations are evidence for that fixture and runtime, not a universal guarantee for unspecified Python versions or implementations.
The acceptance gate uses an independent expected-case manifest, a direct nested-with comparison, a deliberately failing intuition as a negative control, object-identity reconciliation, retained artifacts, and a final ACCEPT / REPAIR / RERUN / HOLD decision. No production systems, external services, network I/O, or third-party packages are required.
Define the operational contract
The operational contract is deliberately narrower than “understand context managers.” A normal with statement calls exit() with the exception type, value, and traceback when the suite exits exceptionally; a truthy return suppresses that exception. With multiple managers, Python specifies behavior equivalent to nesting them.
ExitStack deliberately reproduces that nesting model for dynamically registered exits. The library documentation says registered callbacks are invoked in reverse registration order, and adds the critical rule: when an inner callback suppresses or replaces an exception, outer callbacks receive arguments representing that updated exception state. The pinned v3.13.5 implementation does exactly that: it pops callbacks from the end of the internal deque; a truthy callback clears the current exception; a callback that raises installs the new exception as the pending exception for remaining callbacks.
The release contract is therefore six assertions:
Assertion | Required proof | Reject when |
Cleanup order | callback sequence equals reverse registration order | any missing, duplicated, or reordered callback |
Input exception state | each callback records type and object identity it received | state cannot be reconciled |
Suppression | a truthy push() exit changes the next callback’s exception to None | outer callback still receives suppressed exception |
Replacement | an exit that raises installs that new object for outer exits | outer exit sees old exception or unrelated object |
Final propagation | escaped object is identical to expected body/replacement object | type-only match with wrong identity |
Evidence completeness | runtime, fixture hash, manifest hash and every case retained | missing row, truncated report, unknown runtime |
A useful contrast is Refonte’s ZIP integrity validation playbook: that article also rejects a superficially green API result and preserves occurrence identity before making an acceptance decision. Its identity problem is ZIP member occurrence versus filename; this article’s identity problem is exception object versus exception type or message.

That graph is the state machine we will validate. Resource closure is only one event inside it.
Capture a versioned baseline
The pinned application-level baseline is CPython 3.13.5, released June 11, 2025. Python.org now lists newer 3.13 maintenance releases, including 3.13.18 released October 25, 2026, which is precisely why “Python 3.13” is not an adequate runtime pin.
The implementation source is CPython tag v3.13.5, Lib/contextlib.py. At that tag, ExitStack.__exit__() stores the incoming exception, repeatedly pops the most recently registered callback, rebuilds the exception tuple from the current exception, clears the exception after a truthy exit return, and replaces it after a callback raises. If a replacement remains pending after all callbacks, it is raised.
The documentation and implementation align on the behaviors tested here. One source-version caveat matters: the Python 3.13 documentation site displayed Python 3.13.18 documentation, not a frozen 3.13.5 snapshot. The exact implementation source is consequently anchored to v3.13.5; documentation is used for the language and library contract that remains present in the current 3.13 docs.
Pinned environment for this fixture run:
Component | Pin / observation |
Implementation | CPython |
Semantic version | 3.13.5 |
CPython release date | June 11, 2025 |
CPython source | tag v3.13.5, Lib/contextlib.py |
Executed build string | 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0] |
Executable observed | /opt/pyvenv/bin/python3 |
OS observed | Linux 6.18.57 x86_64, glibc 2.41 |
Local contextlib.py SHA-256 | c1e0d67b2007de11ae93cd36cf6faf38d9ab32656a832d592a49325eec579f96 |
Third-party packages | none |
The local stdlib hash fingerprints the executed file. It is not represented here as a cryptographic proof that the local file is byte-for-byte identical to GitHub’s tagged source.
Pin fixture identity
The measurable assertion is simple: runtime identity and test-artifact identity must be retained before interpreting results.
Use:
python3 --version
python3 - <<'PY'
import contextlib, hashlib, platform, sys
print(sys.version)
print(sys.executable)
print(platform.platform())
print(contextlib.__file__)
print(hashlib.sha256(open(contextlib.__file__, "rb").read()).hexdigest())
PY
sha256sum exitstack_fixture.py expected_manifest.json reconcile.pyFor the executed fixture in this report, the fixture SHA-256 was 71abd6f90fcce524db627d5f3864eb0f251f21c8d531aa234f4464e7482096ff, the manifest SHA-256 was 91de6c78921f52f207b915216ad34076ac86c87934d569fb4541d579f5bdee36, and the reconciliation script SHA-256 was 7e197b2fe8eb580bcc162de1cb7600b7d52245cbcbe92e267f1ad507722c1535.
Reject interpretation and choose HOLD if the runtime version is absent, a test artifact differs without review, or the ledger cannot identify which fixture produced it.
Build the isolated test environment
The fixture needs no pip dependency. That is preferable here: contextlib is in the standard library, and adding pytest or another package would create version and hash surfaces unrelated to the behavior under examination. Python’s own documentation defines ExitStack as a standard-library context manager and documents push(), callback(), and close() directly.
Create an empty disposable directory and a virtual environment without installing packages:
mkdir exitstack-lab
cd exitstack-lab
python3.13 -m venv --without-pip .venv
. .venv/bin/activate
python --version
mkdir -p evidenceA matching machine should report Python 3.13.5; that output is EXPECTED / NOT EXECUTED unless you actually run these commands on your target host.
Because no packages are installed, there is no requirements.txt, lockfile, or third-party wheel hash to pin. The relevant hashes are the fixture, expected manifest, reconciliation program, generated report, and, optionally, the local standard-library source file.
The test itself should use only synthetic exception classes and an in-memory event ledger. No filesystem resource except evidence files is necessary; no socket, database, subprocess service, production credential, or real release payload belongs in this lab. This differs materially from Refonte’s Kubernetes topology-spread validation, which tests scheduling state in a synthetic cluster. That playbook’s central proof is candidate placement under topology changes; ours is a deterministic exception-state transition inside one process.
The core registration helper is intentionally small:
from contextlib import ExitStack
class BodyError(ValueError):
pass
class ReplacementError(RuntimeError):
pass
def push_exit(stack, name, ledger, *, suppress=False, replace=False):
def exit_cb(exc_type, exc, tb):
ledger.append({
"callback": name,
"exc_type": type(exc).__name__ if exc else None,
"exc_id": id(exc) if exc else None,
})
if replace:
new_exc = ReplacementError("replacement")
ledger.append({
"replacement_object_id": id(new_exc),
})
raise new_exc
return suppress
stack.push(exit_cb)Do not reduce the evidence to strings. type(exc).__name__ == "ReplacementError" does not prove that the outer callback received the same replacement instance raised by the inner callback.
Author the expected-case manifest
The expected-case manifest must exist independently of runtime-generated object IDs. Its purpose is to prevent the test from learning its “expected” result from the same execution it is supposed to judge.
A compact version is:
{
"schema": 1,
"cases": {
"order_propagate": {
"event_callbacks": ["C", "B", "A"],
"event_exc_types": ["BodyError", "BodyError", "BodyError"],
"escaped_type": "BodyError",
"after_with_reached": false,
"body_escaped_same_identity": true
},
"suppress_body": {
"event_callbacks": ["suppressor", "outer"],
"event_exc_types": ["BodyError", null],
"escaped_type": null,
"after_with_reached": true
},
"replace_body": {
"event_callbacks": ["replacer", "observer_capture"],
"event_exc_types": ["BodyError", "ReplacementError"],
"escaped_type": "ReplacementError",
"replacement_escaped_same_identity": true,
"replacement_context_is_body": true
},
"replace_then_suppress": {
"event_callbacks": [
"replacer",
"suppress_replacement",
"outer"
],
"event_exc_types": [
"BodyError",
"ReplacementError",
null
],
"escaped_type": null
},
"callback_true_negative": {
"event_callbacks": ["ordinary_callback", "outer"],
"event_exc_types": [null, "BodyError"],
"escaped_type": "BodyError",
"body_escaped_same_identity": true
},
"close_order_no_exception": {
"event_callbacks": ["C", "B", "A"],
"event_exc_types": [null, null, null],
"escaped_type": null
},
"close_replacement": {
"event_callbacks": ["replacer", "outer"],
"event_exc_types": [null, "ReplacementError"],
"escaped_type": "ReplacementError"
}
}
}The expected values follow documented behavior. push() accepts an exit-signature callback whose truthy return can suppress; callback() is different because its function is never passed exception details and cannot suppress. close() starts unwinding as though no exception occurred, so registered exits initially receive three None values.
The manifest should not contain concrete id() integers. Object addresses vary per process. It should contain relational assertions such as replacement_escaped_same_identity: true.
Prove the negative control
The negative control targets a plausible but wrong repair:
with ExitStack() as stack:
def ordinary_cleanup():
return True
stack.callback(ordinary_cleanup)
raise BodyError("body")Someone reading only “callbacks return truthy values to suppress” could expect suppression. That expectation is wrong for ExitStack.callback(). The documentation states that callbacks added through callback() cannot suppress because they are never passed exception details.
The measurable assertion is:
ordinary_callback receives no exception details
outer pushed exit still receives BodyError
BodyError escapesIn the executed fixture, all three conditions were observed.
If this negative control unexpectedly suppresses on the pinned fixture, do not “fix” the expected manifest. Choose HOLD and inspect the runtime, fixture, and actual implementation.
Reproduce the misleading success
The misleading signal is easiest to create when every cleanup operation records success but one exit suppresses the exception.
Use the full fixture structure:
from contextlib import ExitStack
events = []
body_exc = BodyError("body")
def outer(exc_type, exc, tb):
events.append(("outer", exc))
return False
def suppressor(exc_type, exc, tb):
events.append(("suppressor", exc))
return True
with ExitStack() as stack:
stack.push(outer)
stack.push(suppressor)
raise body_exc
print("after with")Expected user-side output on CPython 3.13.5:
after withThat output is EXPECTED / NOT EXECUTED for a reader’s rerun.
If monitoring only asks whether control reached after with, the result looks healthy. It is not enough. The meaningful state is:
suppressor received BodyError("body")
outer received no active exception
no exception escapedThat sequence was observed in the executed fixture for this report.
The Python language rule explains why: when exit() returns true for an exception, the exception is suppressed and execution continues after the with statement. ExitStack extends this nesting model across its dynamically registered exit callbacks.
Successful continuation proves neither that the body succeeded nor that no exception existed. It proves only that nothing remained to propagate past the completed with statement.
A release gate that records only process exit status or “cleanup completed” can therefore erase the event that matters. Preserve the exception-state ledger.
Run a controlled positive comparison
A controlled positive comparison should establish that ExitStack reproduces ordinary nested context-manager behavior for the case we rely on.
Use the same two probes twice, first through normal nesting, then through enter_context():
class Probe:
def init(self, name, log, suppress=False):
self.name = name
self.log = log
self.suppress = suppress
def enter(self):
return self
def exit(self, exc_type, exc, tb):
self.log.append(
(self.name, type(exc).__name__ if exc else None)
)
return self.suppressComparison:
def nested():
log = []
with Probe("outer", log), Probe("inner", log, True):
raise BodyError("body")
return log
def stacked():
log = []
with ExitStack() as stack:
stack.enter_context(Probe("outer", log))
stack.enter_context(Probe("inner", log, True))
raise BodyError("body")
return log
assert nested() == stacked()The executed comparison produced:
nested= ([('inner', 'BodyError', 'body'), ('outer', None, None)], None)
exitstack= ([('inner', 'BodyError', 'body'), ('outer', None, None)], None)
MATCH= TrueThat is an actual observation from this report’s CPython 3.13.5 fixture.
It also matches the language reference: multiple context managers behave as nested with statements, and a truthy inner exit suppresses the exception before control reaches the outer manager.
Refonte’s asyncio.gather exception-lifecycle playbook separates aggregate completion from individual task state and side-effect state rather than inferring everything from the caller-visible exception. This ExitStack article applies the same evidence discipline to a different state machine: callback order, exception identity, suppression and replacement.
Retain failed case artifacts
Every case should write its row before the reconciliation step decides pass or fail. A test that raises before persisting the diagnostic state can turn the most valuable failure into missing evidence.
Recommended directory:
evidence/
00-runtime.txt
01-source-hashes.txt
02-expected-manifest.json
03-observed-report.json
04-reconciliation.txt
05-positive-comparison.txtA failed reconciliation is acceptable test behavior. A missing report is not.
The measurable assertion is that the observed report contains exactly the declared case set, each case contains an ordered event array, and each event identifies callback name, received exception type, nullable exception ID, and action.
Reject the run to HOLD when a case is absent or an unexpected exception prevents final report creation. Do not convert missing evidence into an inferred PASS.
Test negative and boundary cases
Seven cases are sufficient to expose the narrow state transitions without expanding into unrelated APIs.
Case | Purpose | Expected final state | Executed result |
order_propagate | prove LIFO and unchanged propagation | C, B, A all receive same body exception; body exception escapes | matched |
suppress_body | prove suppression updates outer state | suppressor sees body error; outer sees None; no escape | matched |
replace_body | prove replacement | replacer sees body error; outer sees replacement; replacement escapes | matched |
replace_then_suppress | suppress a replacement | middle exit sees replacement and suppresses; outer sees None | matched |
callback_true_negative | prove callback() cannot suppress | ordinary callback return discarded; body error escapes | matched |
close_order_no_exception | prove close() entry state | C, B, A each initially receive None | matched |
close_replacement | prove cleanup can itself fail | replacer starts with None, raises replacement; outer receives replacement | matched |
The last case matters operationally. ExitStack.close() is documented to begin unwinding with arguments indicating that no exception occurred. That does not mean every subsequent callback must receive None: if an earlier callback in LIFO order raises, the pinned implementation installs that new exception and passes it to the remaining outer callbacks.
The replace_body case additionally checks exception context. The pinned source explicitly repairs exception context while simulating nested context managers before re-raising a pending replacement. In the executed fixture, the escaping ReplacementError was the same object that the replacing exit raised, and its context was the original BodyError.
Do not overgeneralize that implementation-specific context-chain detail into a portability guarantee for every Python implementation. The portable contract to prioritize is callback ordering, suppression semantics and caller-visible propagation.
The CSS @starting-style validation playbook treats “the element appeared” as insufficient and instead inspects event lifecycle evidence before ACCEPT / REPAIR / RERUN / HOLD.
Capture a complete evidence ledger
A senior review should be able to reconstruct every transition without rerunning the code. The ledger needs state and identity, not prose such as “cleanup worked.”
For the executed fixture, the condensed ledger was:
Case | Seq | Callback | Received exception | Action | Escaped |
order | 1 | C | BodyError("body") | false | |
order | 2 | B | same body object | false | |
order | 3 | A | same body object | false | same BodyError |
suppress | 1 | suppressor | BodyError | true | |
suppress | 2 | outer | None | false | none |
replace | 1 | replacer | BodyError | raise ReplacementError | |
replace | 2 | observer | same replacement object | false | same replacement |
replace+suppress | 1 | replacer | BodyError | raise replacement | |
replace+suppress | 2 | suppress-replacement | same replacement | true | |
replace+suppress | 3 | outer | None | false | none |
callback negative | 1 | ordinary callback | no exception arguments | returns True, discarded | |
callback negative | 2 | outer | BodyError | false | same body object |
close | 1 | C | None | false | |
close | 2 | B | None | false | |
close | 3 | A | None | false | none |
close replacement | 1 | replacer | None | raise replacement | |
close replacement | 2 | outer | same replacement | false | same replacement |
The complete JSON should also retain numeric id() values from that process. Those numbers are useful only within the run. The evidence assertion should say “observer exception ID equals replacement-object ID” rather than storing an address as a cross-run expected constant.
The report produced during this fixture run had SHA-256 c97be57e499bc6fbf70980676b8cb442c5469c36de948fec6088d4eb929892b8.
Refonte’s data-cleaning workflow also uses retained evidence to make results reproducible. It tracks dataset grain, missingness, duplication, types and joins. For ExitStack, the ledger tracks callback order, exception state and object identity.
Detect missing evidence
A reconciliation program should fail closed:
required = {
"order_propagate",
"suppress_body",
"replace_body",
"replace_then_suppress",
"callback_true_negative",
"close_order_no_exception",
"close_replacement",
}
observed = {case["case"] for case in report["cases"]}
if observed != required:
raise SystemExit("HOLD: incomplete or unexpected case set")Then validate sequence length, callback names and state fields before validating semantics.
The measurable assertion is:
exact case set
+ exact event count per case
+ runtime block present
+ fixture/manifest hashes present
+ reconciliation completed
Any missing term means HOLD. A release decision cannot be reconstructed from “six of seven cases looked fine.”
Reconcile identity and state
Type equality is not identity. This matters most in replacement cases.
Suppose an inner exit raises ReplacementError("replacement"). An outer exit receives some ReplacementError("replacement"), and one later escapes. Comparing only class and message leaves three possibilities unresolved: the same object flowed outward, a new object was substituted, or a wrapper recreated an equivalent-looking exception.
The fixture therefore retains references and asserts:
replacement_seen_by_outer is replacement_raised_by_inner
replacement_escaped is replacement_raised_by_innerFor unchanged propagation it asserts:
escaped is body_excFor suppression it asserts the opposite state transition:
outer_received_exc is None
escaped is NoneObject identity is part of Python’s data model: every object has identity, and is compares that identity. Here we use identity only inside one process and one case; we do not claim id() values have stable cross-run meaning.
The replace_body executed case observed all of the following: the replacer received the original BodyError; the observer received the newly raised ReplacementError; the observer reference was the same replacement object; the final escaped exception was that same replacement object; and the replacement’s context referenced the original body exception.
The independently authored manifest reconciled all seven cases successfully:
RECONCILE_PASS 7 casesThat is an executed observation for this report.
Do not interpret RECONCILE_PASS as “all seven scenarios are desirable in application code.” It means observed runtime behavior matched the declared semantic expectations. A product policy may still classify suppression or replacement as unacceptable for a particular cleanup path.
The exact cleanup-order proof is equally relational. Registration A, then B, then C must yield C, B, A. The library docs and pinned implementation both support that LIFO rule.
Separate guarantees from observations
Four evidence classes should stay visibly separate.
Documented language behavior. A context manager receives the exception information on exceptional exit; a truthy exit() return suppresses it; multiple with items behave like nesting.
Documented ExitStack behavior. Registered exits unwind in reverse order; an inner suppression or replacement updates what outer callbacks receive; push() exits may suppress; callback() cleanups cannot; close() begins with no exception.
Pinned implementation evidence. CPython v3.13.5 pops callbacks LIFO, sets exc = None after a truthy callback, replaces exc after a callback raises, fixes exception context, and raises a remaining replacement after unwinding.
Actual fixture observations. On the CPython 3.13.5 runner used for this report, all seven authored cases reconciled; the positive nested-with comparison matched; and the ordinary callback() return-True negative control did not suppress the body exception.
These evidence classes resolve the most important apparent source tension. The Python documentation by version lists maintenance releases. At the time of the fixture run, the 3.13 branch documentation showed 3.13.18, while the executable was pinned to 3.13.5. That is not a contradiction in the tested semantics, but it is a versioning limitation. The exact 3.13.5 source tag is therefore retained as implementation evidence instead of pretending the moving maintenance documentation page is a frozen 3.13.5 artifact.
Bound the repair
The repair boundary is narrow: change how cleanup exits are registered or how evidence is captured; do not redesign unrelated resource acquisition.
A measurable repair must specify one of these transformations:
callback() -> push() only when suppression is intentionally required
truthy exit -> false return when propagation is required
raising cleanup -> non-raising cleanup only when swallowing that cleanup failure is explicitly correct
ambiguous logging -> identity/state ledger
unversioned test -> pinned runtime + fixture + manifestReject a repair that changes the body operation, calls production systems, catches BaseException broadly without policy, or rewrites the manifest merely to fit an unexpected observation.
Apply a bounded repair
The most common bounded repair is choosing the correct registration API for the intended exception policy.
If cleanup must run but must never suppress, use stack.callback():
with ExitStack() as stack:
stack.callback(remove_synthetic_tempdir)
perform_operation()That is an API-level safeguard: callback()’s return value cannot suppress because exception details are not passed to it. It can still raise its own exception, so “cannot suppress” is not equivalent to “cannot affect failure.”
If the cleanup genuinely needs to inspect and possibly suppress the current exception, use an exit-signature callback registered with push():
def exit_policy(exc_type, exc, tb):
if isinstance(exc, KnownSyntheticError):
record_handled(exc)
return True
return False
with ExitStack() as stack:
stack.push(exit_policy)
perform_operation()That choice should appear in code review as policy, not convenience.
For replacement failures, the repair is usually more cautious. A cleanup that raises can mask the caller-visible body exception by replacing it. The language’s broader cleanup model also recognizes that cleanup code can supersede a saved exception; ExitStack emulates nesting while preserving exception context.
If replacement is not intentional, repair the cleanup so its operational failure is captured through an explicit channel without pretending success. For example, record the cleanup failure and raise an application-defined aggregate or policy exception only if that has been designed and tested.
The safe-release principle is: do not “repair” by adding return True until the process stops failing. That can convert a visible failure into silent continuation while leaving the original condition unresolved.
Test rollback and recovery
Recovery begins from the evidence ledger, not from a guessed root cause.
If a changed callback policy produces an unexpected result, preserve the current report, restore the last reviewed fixture and manifest, recreate the disposable environment, and rerun the complete matrix. Never selectively rerun only the case that changed while carrying forward “passed” rows from another runtime.
A minimal recovery procedure is:
rm -rf .venv evidence
python3.13 -m venv --without-pip .venv
. .venv/bin/activate
mkdir evidence
python --version > evidence/00-runtime.txt
sha256sum \
exitstack_fixture.py \
expected_manifest.json \
reconcile.py \
> evidence/01-source-hashes.txt
cp expected_manifest.json evidence/02-expected-manifest.json
python exitstack_fixture.py \
> evidence/03-observed-report.json
python reconcile.py \
evidence/02-expected-manifest.json \
evidence/03-observed-report.json \
> evidence/04-reconciliation.txtThe final reconciliation output on a matching CPython 3.13.5 environment should be:
RECONCILE_PASS 7 casesThat reader-side result is EXPECTED / NOT EXECUTED until actually run.
Recovery also requires distinguishing cleanup from transaction rollback. ExitStack guarantees invocation of its registered exits according to its context-manager semantics; it does not promise that an arbitrary resource’s cleanup reverses business effects. Its documentation describes callback unwinding, not transactional atomicity.
For a related evidence-first release workflow in another domain, Refonte’s CSS entry-transition validation similarly requires event evidence rather than treating a visually correct end state as proof that the intended transition occurred.
Assign rerun ownership
A rerun needs an accountable artifact owner even in a disposable lab.
The measurable requirements are: one reviewed manifest version, one fixture hash, one runtime pin, one complete report and one reconciliation result. The owner of the rerun must not silently alter any of those during execution.
Use RERUN rather than REPAIR when the code is unchanged but evidence is incomplete, the interpreter is wrong, an artifact hash differs unintentionally, or report generation failed.
Use HOLD when the difference cannot be explained from retained evidence.
No production access is required to resolve any case in this playbook.
Decide ACCEPT, REPAIR, RERUN or HOLD
The release decision is evidence-based, not tied to whether the outer with statement returned normally.
Condition | Decision | Required action |
Runtime and artifact identities match; all expected cases reconcile; application’s declared suppression/replacement policy matches implementation | ACCEPT | retain ledger and hashes with release evidence |
Runtime behavior matches Python semantics, but application registered the wrong cleanup form or unintentionally suppresses/replaces | REPAIR | make the smallest policy change, regenerate fixture hash, rerun all cases |
Fixture or implementation may be correct but run evidence is incomplete, stale or from the wrong pinned runtime | RERUN | recreate isolated environment and execute full matrix |
Behavior differs from manifest and cause is unknown; source/runtime identity is uncertain; comparison and negative control disagree | HOLD | investigate before changing expectations or release state |
A concrete acceptance matrix for the seven fixture cases is:
Case | Expected contract | Observed in this report | Gate implication |
order propagation | C → B → A; same body exception | matched | ACCEPT evidence |
body suppression | suppressor gets body; outer gets None | matched | ACCEPT semantic baseline |
replacement | outer and caller get same replacement | matched | ACCEPT semantic baseline |
replacement suppressed | replacement seen then cleared | matched | ACCEPT semantic baseline |
callback negative | callback() cannot suppress | matched | ACCEPT negative control |
close without exception | initial exits see None | matched | ACCEPT boundary baseline |
close replacement | new cleanup exception flows outward | matched | ACCEPT boundary baseline |
The decision for this fixture baseline is therefore ACCEPT: the executed CPython 3.13.5 observations, independent manifest, negative control and nested-with comparison agreed.
That does not mean every application using suppression or replacement should be accepted. The application still needs a policy saying whether such behavior is intended. The acceptance here is for the reproducibility and correctness of the diagnostic model.
Develop related skills with Refonte Learning
Refonte Learning’s current System Administration program page lists a six-month period, a stated dedication of 10–12 hours per week, system installation and configuration, network administration, security practices, troubleshooting, virtualization, backup and recovery, command-line work and cloud management. The same page states basic computer and network knowledge as a requirement section, separately lists an admission prerequisite of working toward a bachelor’s or higher-level degree, and describes training and internship certificates upon successful completion.
The page also names Windows and Linux systems, networking fundamentals, system security, troubleshooting, virtualization and containers, and backup/disaster recovery in its featured expertise. Its FAQ mentions tools such as Active Directory and PowerShell.
For engineers developing broader operational-diagnosis and recovery skills, the program listing is a reasonable page to inspect directly and evaluate against current learning goals. When ExitStack closes the resources, a successful cleanup signal still does not tell you which Python exception survived. The release-quality answer comes from a versioned state-and-identity ledger, a falsifiable expectation, the negative control, the comparison case and a complete ACCEPT / REPAIR / RERUN / HOLD gate.
