FA-5206 / Exception flow / Open access
Exception handler hierarchy: Places a broad LookupError handler before its specific subclasses · case 01
Places a broad LookupError handler before its specific subclasses and changes the required Python-language result.
ROOT CAUSE
Places a broad LookupError handler before its specific subclasses. The executable reproducer isolates this operation from the rest of the contract.
VERIFIED REPAIR
Dispatch KeyError, IndexError, other LookupError, other Exception, and BaseException separately. Handler order must preserve the specific subclass cases; SystemExit belongs outside Exception.
Unsuccessful approach: The alternative still fails because it places Exception before all specific error handlers.
Case contract
Dispatch KeyError, IndexError, other LookupError, other Exception, and BaseException separately. Handler order must preserve the specific subclass cases; SystemExit belongs outside Exception. 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(kind):
try:
kinds={'key':KeyError,'index':IndexError,'lookup':LookupError,'value':ValueError,'system':SystemExit}
if kind in kinds: raise kinds[kind]('failure')
return 'normal'
except LookupError: return 'lookup'
except KeyError: return 'key'
except IndexError: return 'index'
except Exception: return 'other'
except BaseException: return 'base'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mapping failure', solve('key'), 'key')
check('sequence failure', solve('index'), 'index')
check('generic lookup failure', solve('lookup'), 'lookup')
check('ordinary other error', solve('value'), 'other')
check('termination is not Exception', solve('system'), 'base')
check('normal path', solve('none'), 'normal')
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 |
|---|---|---|---|
| mapping failure | lookup | key | Failed |
| sequence failure | lookup | index | Failed |
| generic lookup failure | lookup | lookup | Passed |
| ordinary other error | other | other | Passed |
| termination is not Exception | base | base | Passed |
| normal path | normal | normal | Passed |
SHA-256 / 858062047b2d0d79cd16aca6cd5ff925b629e02b79e6dfe826f8d4bc63ec5c3b
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(kind):
try:
kinds={'key':KeyError,'index':IndexError,'lookup':LookupError,'value':ValueError,'system':SystemExit}
if kind in kinds: raise kinds[kind]('failure')
return 'normal'
except Exception: return 'other'
except KeyError: return 'key'
except IndexError: return 'index'
except LookupError: return 'lookup'
except BaseException: return 'base'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mapping failure', solve('key'), 'key')
check('sequence failure', solve('index'), 'index')
check('generic lookup failure', solve('lookup'), 'lookup')
check('ordinary other error', solve('value'), 'other')
check('termination is not Exception', solve('system'), 'base')
check('normal path', solve('none'), 'normal')
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 |
|---|---|---|---|
| mapping failure | other | key | Failed |
| sequence failure | other | index | Failed |
| generic lookup failure | other | lookup | Failed |
| ordinary other error | other | other | Passed |
| termination is not Exception | base | base | Passed |
| normal path | normal | normal | Passed |
SHA-256 / ccaeecc2a8e7affc3e9a7e160313f0bb68a449e1d0d484b5a5d1a2421c438eaa
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(kind):
try:
kinds={'key':KeyError,'index':IndexError,'lookup':LookupError,'value':ValueError,'system':SystemExit}
if kind in kinds: raise kinds[kind]('failure')
return 'normal'
except KeyError: return 'key'
except IndexError: return 'index'
except LookupError: return 'lookup'
except Exception: return 'other'
except BaseException: return 'base'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mapping failure', solve('key'), 'key')
check('sequence failure', solve('index'), 'index')
check('generic lookup failure', solve('lookup'), 'lookup')
check('ordinary other error', solve('value'), 'other')
check('termination is not Exception', solve('system'), 'base')
check('normal path', solve('none'), 'normal')
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 |
|---|---|---|---|
| mapping failure | key | key | Passed |
| sequence failure | index | index | Passed |
| generic lookup failure | lookup | lookup | Passed |
| ordinary other error | other | other | Passed |
| termination is not Exception | base | base | Passed |
| normal path | normal | normal | Passed |
SHA-256 / 4697121472f684b4b3074f09990555dd0e6ee0969cb1153e8b5d78b0c9aa48cb
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:47.222496+00:00.
Case digest / 53a738f570929a7ed560dab39c505cc3a504cd1e9380ae9e04d781f1989f5d61