FAILURE MAP
← Case archive

FA-5256 / Exception flow / Open access

Finally return precedence: Returns from finally even when replacement is disabled · case 01

Returns from finally even when replacement is disabled and changes the required Python-language result.

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

ROOT CAUSE

Returns from finally even when replacement is disabled. The executable reproducer isolates this operation from the rest of the contract.

THE FAILURE

Returns from finally even when replacement is disabled. The executable reproducer isolates this operation from the rest of the contract.

Unsuccessful approach: The alternative still fails because it discards the enabled finally return and preserves the pending body outcome.

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')
            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[['cleanup', 'x'], ['try', 'finally']][['body', 'x'], ['try', 'finally']]Failed
body error preserved[['cleanup', 'x'], ['try', 'finally']]['ValueError', ['try', 'finally']]Failed
cleanup replaces successful result[['cleanup', 'x'], ['try', 'finally']][['cleanup', 'x'], ['try', 'finally']]Passed
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[['cleanup', None], ['try', 'finally']][['cleanup', None], ['try', 'finally']]Passed

SHA-256 / db330722c6730fdf621947cf2e90e100e17a00f182568af67abd3a2cab58bf58

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

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 / 6fed589c3e914f5a568108960f1692f0e44eb85489ed7fe1b5669a832718bb20