FAILURE MAP
← Case archive

FA-5221 / Exception flow / Open access

Exception handler hierarchy: Removes the specific IndexError handler · case 01

Removes the specific IndexError handler and changes the required Python-language result.

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

ROOT CAUSE

Removes the specific IndexError handler. 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 uses BaseException for the ordinary fallback and swallows control-flow exceptions.

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 KeyError: return 'key'
    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 failurekeykeyPassed
sequence failurelookupindexFailed
generic lookup failurelookuplookupPassed
ordinary other errorotherotherPassed
termination is not ExceptionbasebasePassed
normal pathnormalnormalPassed

SHA-256 / d474553ca93f75bb7eaff767c01e0d6428ee100c74385df75767ffeaab9ece57

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 KeyError: return 'key'
    except IndexError: return 'index'
    except LookupError: return 'lookup'
    except BaseException: 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 failurekeykeyPassed
sequence failureindexindexPassed
generic lookup failurelookuplookupPassed
ordinary other errorotherotherPassed
termination is not ExceptionotherbaseFailed
normal pathnormalnormalPassed

SHA-256 / c3cafe18899752b1afb983b17b6b0da7698bdf1e6c022c073bd0227bfbcb3825

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

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

Case digest / 8ce4dba45b44674114efa43d74c464d99019d8b5cf9cc1f08388bc4cb6c6f7bd