FAILURE MAP
← Case archive

FA-4641 / Iterator consumption / Open access

Callable iterator misses an equal but distinct sentinel · case 01

An equal sentinel stored in another object fails to stop iteration.

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

ROOT CAUSE

Identity comparison substitutes for the callable iterator protocol equality comparison.

VERIFIED REPAIR

Use equality-based sentinel termination and retain the unconsumed tail.

Unsuccessful approach: Stopping at any falsy item confuses valid empty values with the designated sentinel.

Case contract

Consume callable results until one compares equal to the sentinel. Equal but separately allocated lists terminate iteration; the sentinel is consumed, excluded from output, and later values remain unconsumed.

Why this case matters

A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=[]
    while True:
        v=next(g,y)
        if v is y: break
        a.append(v)
    return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal separately allocated lists stop', solve([[1],[2],[3]], [2]), [[[1]],[[3]]])
check('valid empty list remains', solve([[],[2],[3]], [2]), [[[]],[[3]]])
check('sentinel first', solve([[2],[3]], [2]), [[],[[3]]])
check('empty input', solve([], [2]), [[],[]])
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
equal separately allocated lists stop[[[1], [2], [3]], []][[[1]], [[3]]]Failed
valid empty list remains[[[], [2], [3]], []][[[]], [[3]]]Failed
sentinel first[[[2], [3]], []][[], [[3]]]Failed
empty input[[], []][[], []]Passed

SHA-256 / 731920ee675c04dec974e10ef8591c521562d81121ef9516afe6cfc588a2afee

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=list(it.takewhile(bool,g)); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal separately allocated lists stop', solve([[1],[2],[3]], [2]), [[[1]],[[3]]])
check('valid empty list remains', solve([[],[2],[3]], [2]), [[[]],[[3]]])
check('sentinel first', solve([[2],[3]], [2]), [[],[[3]]])
check('empty input', solve([], [2]), [[],[]])
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
equal separately allocated lists stop[[[1], [2], [3]], []][[[1]], [[3]]]Failed
valid empty list remains[[], [[2], [3]]][[[]], [[3]]]Failed
sentinel first[[[2], [3]], []][[], [[3]]]Failed
empty input[[], []][[], []]Passed

SHA-256 / 2247db381fbf119c6fc6b1a8280624f705590d6c92fc2ae3fe94615df6052828

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=list(iter(lambda:next(g,y),y)); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal separately allocated lists stop', solve([[1],[2],[3]], [2]), [[[1]],[[3]]])
check('valid empty list remains', solve([[],[2],[3]], [2]), [[[]],[[3]]])
check('sentinel first', solve([[2],[3]], [2]), [[],[[3]]])
check('empty input', solve([], [2]), [[],[]])
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
equal separately allocated lists stop[[[1]], [[3]]][[[1]], [[3]]]Passed
valid empty list remains[[[]], [[3]]][[[]], [[3]]]Passed
sentinel first[[], [[3]]][[], [[3]]]Passed
empty input[[], []][[], []]Passed

SHA-256 / 4a6420813461f28a9d1051426d13cd291a4ce68758f48b15d58ee6f67503368f

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

Case digest / 180d5e74a4346ad3f3835f071548e00292e2bee5ad81c4432499a3572b732f39