FAILURE MAP
← Case archive

FA-5211 / Exception flow / Open access

Exception handler hierarchy: Places Exception before all specific error handlers · case 01

Places Exception before all specific error handlers and changes the required Python-language result.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Places Exception before all specific error handlers. The executable reproducer isolates this operation from the rest of the contract.

THE FAILURE

Places Exception before all specific error handlers. The executable reproducer isolates this operation from the rest of the contract.

Unsuccessful approach: The alternative still fails because it catches TypeError in the slot intended for KeyError.

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 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 fixtureActualExpectedOutcome
mapping failureotherkeyFailed
sequence failureotherindexFailed
generic lookup failureotherlookupFailed
ordinary other errorotherotherPassed
termination is not ExceptionbasebasePassed
normal pathnormalnormalPassed

SHA-256 / ccaeecc2a8e7affc3e9a7e160313f0bb68a449e1d0d484b5a5d1a2421c438eaa

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 TypeError: 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 fixtureActualExpectedOutcome
mapping failurelookupkeyFailed
sequence failureindexindexPassed
generic lookup failurelookuplookupPassed
ordinary other errorotherotherPassed
termination is not ExceptionbasebasePassed
normal pathnormalnormalPassed

SHA-256 / 2d13c1fad589da064fce2e0a611d08a79498f26d8ba6db81d7bc1b6f2d36e66c

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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.266069+00:00.

Case digest / d6c1e8fd1afcdf9c7eb0680de3591239fd1d7716bce821cd6bef2833a915f2ff