FAILURE MAP
← Case archive

FA-5276 / Exception flow / Open access

Finally return precedence: Conditions finally replacement on payload truthiness · case 01

Conditions finally replacement on payload truthiness and changes the required Python-language result.

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

ROOT CAUSE

Conditions finally replacement on payload truthiness. The executable reproducer isolates this operation from the rest of the contract.

THE FAILURE

Conditions finally replacement on payload truthiness. The executable reproducer isolates this operation from the rest of the contract.

Unsuccessful approach: The alternative still fails because it returns from finally even when replacement is disabled.

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 value: 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[['cleanup', 'x'], ['try', 'finally']][['cleanup', 'x'], ['try', 'finally']]Passed
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 / c05d26c3abfd118a8e8701435dc4af88ace7ca3c9400b67372b4598d259b6a3c

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

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 / 7790e01b16cf346c52bae60a3d09828c56306dffe0689b72821d525786cd5fd1