FAILURE MAP
← Case archive

FA-5261 / Exception flow / Open access

Finally return precedence: Discards the enabled finally return and preserves the pending body outcome · case 01

Discards the enabled finally return and preserves the pending body outcome and changes the required Python-language result.

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

ROOT CAUSE

Discards the enabled finally return and preserves the pending body outcome. The executable reproducer isolates this operation from the rest of the contract.

THE FAILURE

Discards the enabled finally return and preserves the pending body outcome. The executable reproducer isolates this operation from the rest of the contract.

Unsuccessful approach: The alternative still fails because it applies the finally return only to exceptional body completion.

Case 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.

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(value, error, override):
    log=[]
    def f():
        try:
            log.append('try')
            if error: raise ValueError('body')
            return ['body',value]
        finally:
            log.append('finally')
            pass
    try: result=f()
    except ValueError: result='ValueError'
    return [result,log]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordinary body result', solve('x', False, False), [['body', 'x'], ['try', 'finally']])
check('body error preserved', solve('x', True, False), ['ValueError', ['try', 'finally']])
check('cleanup replaces successful result', solve('x', False, True), [['cleanup', 'x'], ['try', 'finally']])
check('cleanup suppresses body error', solve('x', True, True), [['cleanup', 'x'], ['try', 'finally']])
check('zero cleanup return valid', solve(0, True, True), [['cleanup', 0], ['try', 'finally']])
check('None cleanup return valid', solve(None, False, True), [['cleanup', None], ['try', 'finally']])
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
ordinary body result[['body', 'x'], ['try', 'finally']][['body', 'x'], ['try', 'finally']]Passed
body error preserved['ValueError', ['try', 'finally']]['ValueError', ['try', 'finally']]Passed
cleanup replaces successful result[['body', 'x'], ['try', 'finally']][['cleanup', 'x'], ['try', 'finally']]Failed
cleanup suppresses body error['ValueError', ['try', 'finally']][['cleanup', 'x'], ['try', 'finally']]Failed
zero cleanup return valid['ValueError', ['try', 'finally']][['cleanup', 0], ['try', 'finally']]Failed
None cleanup return valid[['body', None], ['try', 'finally']][['cleanup', None], ['try', 'finally']]Failed

SHA-256 / f9e76ebd082f85b93f7b8792e68d639bbd87923b99b291bb320e776a8621faf0

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(value, error, override):
    log=[]
    def f():
        try:
            log.append('try')
            if error: raise ValueError('body')
            return ['body',value]
        finally:
            log.append('finally')
            if override and error: return ['cleanup',value]
    try: result=f()
    except ValueError: result='ValueError'
    return [result,log]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordinary body result', solve('x', False, False), [['body', 'x'], ['try', 'finally']])
check('body error preserved', solve('x', True, False), ['ValueError', ['try', 'finally']])
check('cleanup replaces successful result', solve('x', False, True), [['cleanup', 'x'], ['try', 'finally']])
check('cleanup suppresses body error', solve('x', True, True), [['cleanup', 'x'], ['try', 'finally']])
check('zero cleanup return valid', solve(0, True, True), [['cleanup', 0], ['try', 'finally']])
check('None cleanup return valid', solve(None, False, True), [['cleanup', None], ['try', 'finally']])
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
ordinary body result[['body', 'x'], ['try', 'finally']][['body', 'x'], ['try', 'finally']]Passed
body error preserved['ValueError', ['try', 'finally']]['ValueError', ['try', 'finally']]Passed
cleanup replaces successful result[['body', 'x'], ['try', 'finally']][['cleanup', 'x'], ['try', 'finally']]Failed
cleanup suppresses body error[['cleanup', 'x'], ['try', 'finally']][['cleanup', 'x'], ['try', 'finally']]Passed
zero cleanup return valid[['cleanup', 0], ['try', 'finally']][['cleanup', 0], ['try', 'finally']]Passed
None cleanup return valid[['body', None], ['try', 'finally']][['cleanup', None], ['try', 'finally']]Failed

SHA-256 / 4b9099901c368375b6142bdb27192f69cc6241319b3756ba834a9c94a5ced46d

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

Case digest / 1235fcd747a2ae1198d23dd9af90e1113e10c703c5ce1a2e2faa1e9fac83232e