FAILURE MAP
← Case archive

FA-5266 / Exception flow / Open access

Finally return precedence: Applies the finally return only to exceptional body completion · case 01

Applies the finally return only to exceptional body completion and changes the required Python-language result.

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

ROOT CAUSE

Applies the finally return only to exceptional body completion. The executable reproducer isolates this operation from the rest of the contract.

THE FAILURE

Applies the finally return only to exceptional body completion. The executable reproducer isolates this operation from the rest of the contract.

Unsuccessful approach: The alternative still fails because it refuses to let a finally return suppress a pending exception.

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')
            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

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 not 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[['cleanup', 'x'], ['try', 'finally']][['cleanup', 'x'], ['try', 'finally']]Passed
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[['cleanup', None], ['try', 'finally']][['cleanup', None], ['try', 'finally']]Passed

SHA-256 / fd8bffbb93fed006c26a66a569571b915c15631454a399174e379d489f4c9b6a

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 / ac04eb03da58dc98cfa7cef6dad33d38eb03454ad886102fb4172cfc9cd99f2a