{"abstract":"Catches TypeError in the slot intended for KeyError and changes the required Python-language result.","category":"Exception flow","checks":6,"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.","evaluation_group":"xl-exception-handler-hierarchy","failed_approach":"The alternative still fails because it removes the specific IndexError handler.","family":"xl-exception-handler-hierarchy-wrong-key-subclass","id":"FA-5216","implementations":{"attempt":{"sha256":"d474553ca93f75bb7eaff767c01e0d6428ee100c74385df75767ffeaab9ece57","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(kind):\n    try:\n        kinds={'key':KeyError,'index':IndexError,'lookup':LookupError,'value':ValueError,'system':SystemExit}\n        if kind in kinds: raise kinds[kind]('failure')\n        return 'normal'\n    except KeyError: return 'key'\n    except LookupError: return 'lookup'\n    except Exception: return 'other'\n    except BaseException: return 'base'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('mapping failure', solve('key'), 'key')\ncheck('sequence failure', solve('index'), 'index')\ncheck('generic lookup failure', solve('lookup'), 'lookup')\ncheck('ordinary other error', solve('value'), 'other')\ncheck('termination is not Exception', solve('system'), 'base')\ncheck('normal path', solve('none'), 'normal')\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"2d13c1fad589da064fce2e0a611d08a79498f26d8ba6db81d7bc1b6f2d36e66c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(kind):\n    try:\n        kinds={'key':KeyError,'index':IndexError,'lookup':LookupError,'value':ValueError,'system':SystemExit}\n        if kind in kinds: raise kinds[kind]('failure')\n        return 'normal'\n    except TypeError: return 'key'\n    except IndexError: return 'index'\n    except LookupError: return 'lookup'\n    except Exception: return 'other'\n    except BaseException: return 'base'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('mapping failure', solve('key'), 'key')\ncheck('sequence failure', solve('index'), 'index')\ncheck('generic lookup failure', solve('lookup'), 'lookup')\ncheck('ordinary other error', solve('value'), 'other')\ncheck('termination is not Exception', solve('system'), 'base')\ncheck('normal path', solve('none'), 'normal')\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"4697121472f684b4b3074f09990555dd0e6ee0969cb1153e8b5d78b0c9aa48cb","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(kind):\n    try:\n        kinds={'key':KeyError,'index':IndexError,'lookup':LookupError,'value':ValueError,'system':SystemExit}\n        if kind in kinds: raise kinds[kind]('failure')\n        return 'normal'\n    except KeyError: return 'key'\n    except IndexError: return 'index'\n    except LookupError: return 'lookup'\n    except Exception: return 'other'\n    except BaseException: return 'base'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('mapping failure', solve('key'), 'key')\ncheck('sequence failure', solve('index'), 'index')\ncheck('generic lookup failure', solve('lookup'), 'lookup')\ncheck('ordinary other error', solve('value'), 'other')\ncheck('termination is not Exception', solve('system'), 'base')\ncheck('normal path', solve('none'), 'normal')\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":" 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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"xl-exception-handler-hierarchy-wrong-key-subclass","generated_at":"2026-09-29T14:37:47.223102+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"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.","repair":"Dispatch KeyError, IndexError, other LookupError, other Exception, and BaseException separately. Handler order must preserve the specific subclass cases; SystemExit belongs outside Exception.","root_cause":"Catches TypeError in the slot intended for KeyError. The executable reproducer isolates this operation from the rest of the contract.","sha256":"a48557e9c0ffadfff7f44bb639250c91218ad8acc4cc34683c0c9afb952f8650","title":"Exception handler hierarchy: Catches TypeError in the slot intended for KeyError · case 01","variant":1,"variant_policy":"The five numbered cases rerun the same authored boundary fixtures; they are reproducibility runs, not independent input variants.","verification":{"attempt":{"elapsed_ms":37.939,"exit_code":1,"observations":[{"actual":"key","check":"mapping failure","expected":"key","passed":true},{"actual":"lookup","check":"sequence failure","expected":"index","passed":false},{"actual":"lookup","check":"generic lookup failure","expected":"lookup","passed":true},{"actual":"other","check":"ordinary other error","expected":"other","passed":true},{"actual":"base","check":"termination is not Exception","expected":"base","passed":true},{"actual":"normal","check":"normal path","expected":"normal","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"mapping failure\", \"actual\": \"key\", \"expected\": \"key\", \"passed\": true}, {\"check\": \"sequence failure\", \"actual\": \"lookup\", \"expected\": \"index\", \"passed\": false}, {\"check\": \"generic lookup failure\", \"actual\": \"lookup\", \"expected\": \"lookup\", \"passed\": true}, {\"check\": \"ordinary other error\", \"actual\": \"other\", \"expected\": \"other\", \"passed\": true}, {\"check\": \"termination is not Exception\", \"actual\": \"base\", \"expected\": \"base\", \"passed\": true}, {\"check\": \"normal path\", \"actual\": \"normal\", \"expected\": \"normal\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.304,"exit_code":1,"observations":[{"actual":"lookup","check":"mapping failure","expected":"key","passed":false},{"actual":"index","check":"sequence failure","expected":"index","passed":true},{"actual":"lookup","check":"generic lookup failure","expected":"lookup","passed":true},{"actual":"other","check":"ordinary other error","expected":"other","passed":true},{"actual":"base","check":"termination is not Exception","expected":"base","passed":true},{"actual":"normal","check":"normal path","expected":"normal","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"mapping failure\", \"actual\": \"lookup\", \"expected\": \"key\", \"passed\": false}, {\"check\": \"sequence failure\", \"actual\": \"index\", \"expected\": \"index\", \"passed\": true}, {\"check\": \"generic lookup failure\", \"actual\": \"lookup\", \"expected\": \"lookup\", \"passed\": true}, {\"check\": \"ordinary other error\", \"actual\": \"other\", \"expected\": \"other\", \"passed\": true}, {\"check\": \"termination is not Exception\", \"actual\": \"base\", \"expected\": \"base\", \"passed\": true}, {\"check\": \"normal path\", \"actual\": \"normal\", \"expected\": \"normal\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.895,"exit_code":0,"observations":[{"actual":"key","check":"mapping failure","expected":"key","passed":true},{"actual":"index","check":"sequence failure","expected":"index","passed":true},{"actual":"lookup","check":"generic lookup failure","expected":"lookup","passed":true},{"actual":"other","check":"ordinary other error","expected":"other","passed":true},{"actual":"base","check":"termination is not Exception","expected":"base","passed":true},{"actual":"normal","check":"normal path","expected":"normal","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"mapping failure\", \"actual\": \"key\", \"expected\": \"key\", \"passed\": true}, {\"check\": \"sequence failure\", \"actual\": \"index\", \"expected\": \"index\", \"passed\": true}, {\"check\": \"generic lookup failure\", \"actual\": \"lookup\", \"expected\": \"lookup\", \"passed\": true}, {\"check\": \"ordinary other error\", \"actual\": \"other\", \"expected\": \"other\", \"passed\": true}, {\"check\": \"termination is not Exception\", \"actual\": \"base\", \"expected\": \"base\", \"passed\": true}, {\"check\": \"normal path\", \"actual\": \"normal\", \"expected\": \"normal\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}