{"abstract":"Returns from finally even when replacement is disabled 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 discards the enabled finally return and preserves the pending body outcome.","family":"xl-finally-return-precedence-unconditional-cleanup-return","id":"FA-5256","implementations":{"attempt":{"sha256":"f9e76ebd082f85b93f7b8792e68d639bbd87923b99b291bb320e776a8621faf0","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            pass\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":"db330722c6730fdf621947cf2e90e100e17a00f182568af67abd3a2cab58bf58","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            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-unconditional-cleanup-return","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":"Returns from finally even when replacement is disabled. The executable reproducer isolates this operation from the rest of the contract.","sha256":"6fed589c3e914f5a568108960f1692f0e44eb85489ed7fe1b5669a832718bb20","title":"Finally return precedence: Returns from finally even when replacement is disabled · 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":36.078,"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":["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":[["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\": [\"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\": [[\"body\", null], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", null], [\"try\", \"finally\"]], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":35.79,"exit_code":1,"observations":[{"actual":[["cleanup","x"],["try","finally"]],"check":"ordinary body result","expected":[["body","x"],["try","finally"]],"passed":false},{"actual":[["cleanup","x"],["try","finally"]],"check":"body error preserved","expected":["ValueError",["try","finally"]],"passed":false},{"actual":[["cleanup","x"],["try","finally"]],"check":"cleanup replaces successful result","expected":[["cleanup","x"],["try","finally"]],"passed":true},{"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":[["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\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"expected\": [[\"body\", \"x\"], [\"try\", \"finally\"]], \"passed\": false}, {\"check\": \"body error preserved\", \"actual\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"expected\": [\"ValueError\", [\"try\", \"finally\"]], \"passed\": false}, {\"check\": \"cleanup replaces successful result\", \"actual\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", \"x\"], [\"try\", \"finally\"]], \"passed\": true}, {\"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\": [[\"cleanup\", null], [\"try\", \"finally\"]], \"expected\": [[\"cleanup\", null], [\"try\", \"finally\"]], \"passed\": true}], \"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."}}