FAILURE MAP
← Case archive

FA-2881 / Lexical grammars / Open access

An identifier rejects underscores and admits leading digits · case 01

An identifier rejects underscores and admits leading digits.

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

ROOT CAUSE

The implementation applies an operation whose text or grammar semantics violate this contract: Validate Python Unicode identifiers, including keywords as lexical identifiers.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Validate Python Unicode identifiers, including keywords as lexical identifiers.

Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.

Case contract

Validate Python Unicode identifiers, including keywords as lexical identifiers.

Why this case matters

A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isalnum()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('_a'), True)
check('boundary 2', solve('1a'), False)
check('boundary 3', solve('á'), True)
check('boundary 4', solve('class'), True)
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
boundary 1FalseTrueFailed
boundary 2TrueFalseFailed
boundary 3FalseTrueFailed
boundary 4TrueTruePassed

SHA-256 / e9eb96f83099a97e1bdc44fbd3a3fce9264778c1d923c58922675d919becc834

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bool(x) and (x[0].isalpha() or x[0]=='_') and all(c.isalnum() or c=='_' for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('_a'), True)
check('boundary 2', solve('1a'), False)
check('boundary 3', solve('á'), True)
check('boundary 4', solve('class'), True)
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
boundary 1TrueTruePassed
boundary 2FalseFalsePassed
boundary 3FalseTrueFailed
boundary 4TrueTruePassed

SHA-256 / 76aa54116c5b3f28da1cbe38c958b21e0d37f9f11b74f869579251b4153cefc5

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isidentifier()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('_a'), True)
check('boundary 2', solve('1a'), False)
check('boundary 3', solve('á'), True)
check('boundary 4', solve('class'), True)
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
boundary 1TrueTruePassed
boundary 2FalseFalsePassed
boundary 3TrueTruePassed
boundary 4TrueTruePassed

SHA-256 / 65d0e6d07ae251b4587e488e0afdd4a734456321613fb67ba1e2ed1aed9417d6

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

Case digest / 073c69ef0d26ce75564e4aaf436c54fc1aac147b18578d55ee04bc40f2beec42