FA-5136 / Context managers / Open access
Context exception suppression: Discards the truthy __exit__ decision and propagates ValueError · case 01
Discards the truthy __exit__ decision and propagates ValueError and changes the required Python-language result.
ROOT CAUSE
Discards the truthy __exit__ decision and propagates ValueError. The executable reproducer isolates this operation from the rest of the contract.
VERIFIED REPAIR
A context manager suppresses only ValueError when enabled. __exit__ observes the actual exception class or None on normal exit; unsuppressed exceptions reach the outer handler and skip after.
Unsuccessful approach: The alternative still fails because it suppresses ValueError even when the policy is disabled.
Case contract
A context manager suppresses only ValueError when enabled. __exit__ observes the actual exception class or None on normal exit; unsuppressed exceptions reach the outer handler and skip after. Inputs use the finite Python types shown in the fixtures. An error string denotes the specified caught exception, not an unhandled process failure.
Why this case matters
Runs Python standard-library language operations in a deterministic local reproducer. Literal expected answers are authored independently. Related defects share an evaluation group to avoid benchmark split leakage.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(error, enabled):
log=[]
class Manager:
def __enter__(self):
log.append('enter')
return self
def __exit__(self, typ, exc, tb):
log.append('exit:'+('none' if typ is None else typ.__name__))
return False
try:
with Manager():
log.append('body')
if error=='value': raise ValueError('value')
if error=='key': raise KeyError('key')
if error=='type': raise TypeError('type')
log.append('after')
except Exception as exc:
log.append('caught:'+type(exc).__name__)
return log
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal exit', solve('none', True), ['enter', 'body', 'exit:none', 'after'])
check('selected error suppressed', solve('value', True), ['enter', 'body', 'exit:ValueError', 'after'])
check('disabled propagation', solve('value', False), ['enter', 'body', 'exit:ValueError', 'caught:ValueError'])
check('unrelated error propagates', solve('key', True), ['enter', 'body', 'exit:KeyError', 'caught:KeyError'])
check('other unrelated type', solve('type', True), ['enter', 'body', 'exit:TypeError', 'caught:TypeError'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal exit | ['enter', 'body', 'exit:none', 'after'] | ['enter', 'body', 'exit:none', 'after'] | Passed |
| selected error suppressed | ['enter', 'body', 'exit:ValueError', 'caught:ValueError'] | ['enter', 'body', 'exit:ValueError', 'after'] | Failed |
| disabled propagation | ['enter', 'body', 'exit:ValueError', 'caught:ValueError'] | ['enter', 'body', 'exit:ValueError', 'caught:ValueError'] | Passed |
| unrelated error propagates | ['enter', 'body', 'exit:KeyError', 'caught:KeyError'] | ['enter', 'body', 'exit:KeyError', 'caught:KeyError'] | Passed |
| other unrelated type | ['enter', 'body', 'exit:TypeError', 'caught:TypeError'] | ['enter', 'body', 'exit:TypeError', 'caught:TypeError'] | Passed |
SHA-256 / f7b05733326cc9137c0c1d7c65d636e88597f2eec8c19b780597de98a6a5e349
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(error, enabled):
log=[]
class Manager:
def __enter__(self):
log.append('enter')
return self
def __exit__(self, typ, exc, tb):
log.append('exit:'+('none' if typ is None else typ.__name__))
return typ is ValueError
try:
with Manager():
log.append('body')
if error=='value': raise ValueError('value')
if error=='key': raise KeyError('key')
if error=='type': raise TypeError('type')
log.append('after')
except Exception as exc:
log.append('caught:'+type(exc).__name__)
return log
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal exit', solve('none', True), ['enter', 'body', 'exit:none', 'after'])
check('selected error suppressed', solve('value', True), ['enter', 'body', 'exit:ValueError', 'after'])
check('disabled propagation', solve('value', False), ['enter', 'body', 'exit:ValueError', 'caught:ValueError'])
check('unrelated error propagates', solve('key', True), ['enter', 'body', 'exit:KeyError', 'caught:KeyError'])
check('other unrelated type', solve('type', True), ['enter', 'body', 'exit:TypeError', 'caught:TypeError'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal exit | ['enter', 'body', 'exit:none', 'after'] | ['enter', 'body', 'exit:none', 'after'] | Passed |
| selected error suppressed | ['enter', 'body', 'exit:ValueError', 'after'] | ['enter', 'body', 'exit:ValueError', 'after'] | Passed |
| disabled propagation | ['enter', 'body', 'exit:ValueError', 'after'] | ['enter', 'body', 'exit:ValueError', 'caught:ValueError'] | Failed |
| unrelated error propagates | ['enter', 'body', 'exit:KeyError', 'caught:KeyError'] | ['enter', 'body', 'exit:KeyError', 'caught:KeyError'] | Passed |
| other unrelated type | ['enter', 'body', 'exit:TypeError', 'caught:TypeError'] | ['enter', 'body', 'exit:TypeError', 'caught:TypeError'] | Passed |
SHA-256 / 13f503211282da046e42b6d88dae8b6bab7b377d13143c436ba23d5a8a15ad17
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(error, enabled):
log=[]
class Manager:
def __enter__(self):
log.append('enter')
return self
def __exit__(self, typ, exc, tb):
log.append('exit:'+('none' if typ is None else typ.__name__))
return typ is ValueError and enabled
try:
with Manager():
log.append('body')
if error=='value': raise ValueError('value')
if error=='key': raise KeyError('key')
if error=='type': raise TypeError('type')
log.append('after')
except Exception as exc:
log.append('caught:'+type(exc).__name__)
return log
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal exit', solve('none', True), ['enter', 'body', 'exit:none', 'after'])
check('selected error suppressed', solve('value', True), ['enter', 'body', 'exit:ValueError', 'after'])
check('disabled propagation', solve('value', False), ['enter', 'body', 'exit:ValueError', 'caught:ValueError'])
check('unrelated error propagates', solve('key', True), ['enter', 'body', 'exit:KeyError', 'caught:KeyError'])
check('other unrelated type', solve('type', True), ['enter', 'body', 'exit:TypeError', 'caught:TypeError'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal exit | ['enter', 'body', 'exit:none', 'after'] | ['enter', 'body', 'exit:none', 'after'] | Passed |
| selected error suppressed | ['enter', 'body', 'exit:ValueError', 'after'] | ['enter', 'body', 'exit:ValueError', 'after'] | Passed |
| disabled propagation | ['enter', 'body', 'exit:ValueError', 'caught:ValueError'] | ['enter', 'body', 'exit:ValueError', 'caught:ValueError'] | Passed |
| unrelated error propagates | ['enter', 'body', 'exit:KeyError', 'caught:KeyError'] | ['enter', 'body', 'exit:KeyError', 'caught:KeyError'] | Passed |
| other unrelated type | ['enter', 'body', 'exit:TypeError', 'caught:TypeError'] | ['enter', 'body', 'exit:TypeError', 'caught:TypeError'] | Passed |
SHA-256 / 28bc3eb1a5f50a36a2e2c15669ed1394b41285c80e1d21dfd5ce2359cd5baecb
Verification & scope
This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:37:46.462454+00:00.
Case digest / 80304b447d283cc3853225e2d9b6cc0b4d4eeb1ea38b050bce7c4197ea9f5200