{"abstract":"Applies the finally return only to exceptional body completion and changes the required Python-language result.","category":"Exception flow","checks":6,"contract":"Run cleanup for both body returns and exceptions. Only when override is true does a finally return replace the pending body result or suppress its ValueError; otherwise preserve the pending outcome. Inputs use the finite Python types shown in the fixtures. An error string denotes the specified caught exception, not an unhandled process failure.","contract_signature":"value, error, override","evaluation_group":"xl-finally-return-precedence","failed_approach":"The alternative still fails because it refuses to let a finally return suppress a pending exception.","family":"xl-finally-return-precedence-error-only-override","id":"FA-5266","implementations":{"attempt":{"sha256":"fd8bffbb93fed006c26a66a569571b915c15631454a399174e379d489f4c9b6a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(value, error, override):\n    log=[]\n    def f():\n        try:\n            log.append('try')\n            if error: raise ValueError('body')\n            return ['body',value]\n        finally:\n            log.append('finally')\n            if override and not error: return ['cleanup',value]\n    try: result=f()\n    except ValueError: result='ValueError'\n    return [result,log]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('ordinary body result', solve('x', False, False), [['body', 'x'], ['try', 'finally']])\ncheck('body error preserved', solve('x', True, False), ['ValueError', ['try', 'finally']])\ncheck('cleanup replaces successful result', solve('x', False, True), [['cleanup', 'x'], ['try', 'finally']])\ncheck('cleanup suppresses body error', solve('x', True, True), [['cleanup', 'x'], ['try', 'finally']])\ncheck('zero cleanup return valid', solve(0, True, True), [['cleanup', 0], ['try', 'finally']])\ncheck('None cleanup return valid', solve(None, False, True), [['cleanup', None], ['try', 'finally']])\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":"4b9099901c368375b6142bdb27192f69cc6241319b3756ba834a9c94a5ced46d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(value, error, override):\n    log=[]\n    def f():\n        try:\n            log.append('try')\n            if error: raise ValueError('body')\n            return ['body',value]\n        finally:\n            log.append('finally')\n            if override and error: return ['cleanup',value]\n    try: result=f()\n    except ValueError: result='ValueError'\n    return [result,log]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('ordinary body result', solve('x', False, False), [['body', 'x'], ['try', 'finally']])\ncheck('body error preserved', solve('x', True, False), ['ValueError', ['try', 'finally']])\ncheck('cleanup replaces successful result', solve('x', False, True), [['cleanup', 'x'], ['try', 'finally']])\ncheck('cleanup suppresses body error', solve('x', True, True), [['cleanup', 'x'], ['try', 'finally']])\ncheck('zero cleanup return valid', solve(0, True, True), [['cleanup', 0], ['try', 'finally']])\ncheck('None cleanup return valid', solve(None, False, True), [['cleanup', None], ['try', 'finally']])\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-finally-return-precedence-error-only-override","generated_at":"2026-09-29T14:37:47.863865+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.","root_cause":"Applies the finally return only to exceptional body completion. The executable reproducer isolates this operation from the rest of the contract.","sha256":"ac04eb03da58dc98cfa7cef6dad33d38eb03454ad886102fb4172cfc9cd99f2a","title":"Finally return precedence: Applies the finally return only to exceptional body completion · case 01","variant":1,"variant_policy":"The five numbered cases rerun the same authored boundary fixtures; they are reproducibility runs, not independent input variants.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":38.192,"exit_code":1,"observations":[{"actual":[["body","x"],["try","finally"]],"check":"ordinary body result","expected":[["body","x"],["try","finally"]],"passed":true},{"actual":["ValueError",["try","finally"]],"check":"body error preserved","expected":["ValueError",["try","finally"]],"passed":true},{"actual":[["cleanup","x"],["try","finally"]],"check":"cleanup replaces successful result","expected":[["cleanup","x"],["try","finally"]],"passed":true},{"actual":["ValueError",["try","finally"]],"check":"cleanup suppresses body error","expected":[["cleanup","x"],["try","finally"]],"passed":false},{"actual":["ValueError",["try","finally"]],"check":"zero cleanup return valid","expected":[["cleanup",0],["try","finally"]],"passed":false},{"actual":[["cleanup",null],["try","finally"]],"check":"None cleanup return valid","expected":[["cleanup",null],["try","finally"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"ordinary body result\", \"actual\": [[\"body\", \"x\"], [\"try\", \"finally\"]], \"expected\": [[\"body\", \"x\"], [\"try\", \"finally\"]], \"passed\": true}, {\"check\": \"body error preserved\", \"actual\": [\"ValueError\", [\"try\", \"finally\"]], \"expected\": [\"ValueError\", [\"try\", \"finally\"]], \"passed\": true}, {\"check\": \"cleanup replaces successful result\", \"actual\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"passed\": true}, {\"check\": \"cleanup suppresses body error\", \"actual\": [\"ValueError\", [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"passed\": false}, {\"check\": \"zero cleanup return valid\", \"actual\": [\"ValueError\", [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", 0], [\"try\", \"finally\"]], \"passed\": false}, {\"check\": \"None cleanup return valid\", \"actual\": [[\"cleanup\", null], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", null], [\"try\", \"finally\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":35.367,"exit_code":1,"observations":[{"actual":[["body","x"],["try","finally"]],"check":"ordinary body result","expected":[["body","x"],["try","finally"]],"passed":true},{"actual":["ValueError",["try","finally"]],"check":"body error preserved","expected":["ValueError",["try","finally"]],"passed":true},{"actual":[["body","x"],["try","finally"]],"check":"cleanup replaces successful result","expected":[["cleanup","x"],["try","finally"]],"passed":false},{"actual":[["cleanup","x"],["try","finally"]],"check":"cleanup suppresses body error","expected":[["cleanup","x"],["try","finally"]],"passed":true},{"actual":[["cleanup",0],["try","finally"]],"check":"zero cleanup return valid","expected":[["cleanup",0],["try","finally"]],"passed":true},{"actual":[["body",null],["try","finally"]],"check":"None cleanup return valid","expected":[["cleanup",null],["try","finally"]],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"ordinary body result\", \"actual\": [[\"body\", \"x\"], [\"try\", \"finally\"]], \"expected\": [[\"body\", \"x\"], [\"try\", \"finally\"]], \"passed\": true}, {\"check\": \"body error preserved\", \"actual\": [\"ValueError\", [\"try\", \"finally\"]], \"expected\": [\"ValueError\", [\"try\", \"finally\"]], \"passed\": true}, {\"check\": \"cleanup replaces successful result\", \"actual\": [[\"body\", \"x\"], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"passed\": false}, {\"check\": \"cleanup suppresses body error\", \"actual\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"passed\": true}, {\"check\": \"zero cleanup return valid\", \"actual\": [[\"cleanup\", 0], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", 0], [\"try\", \"finally\"]], \"passed\": true}, {\"check\": \"None cleanup return valid\", \"actual\": [[\"body\", null], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", null], [\"try\", \"finally\"]], \"passed\": false}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}