bpo-29593: Improve UnboundLocalError message. by Carreau · Pull Request #141 · python/cpython
Raymond Hettinger reported during PyCon Canada 2016 Keynote (~20m30 sec)
That unbound local error message was inaccurate, it state that :
> local variable 'xxx' referenced before assignment
Though it can be assigned and deleted.
for a toy example:
def foo():
x = 1
del x
print(x)
foo()
Do the same for free variable.
def multiplier(n):
def multiply(x):
return x * n
del n
return multiply
Carreau
changed the title
Improve UnboundLocalError message.
bpo-29593: Improve UnboundLocalError message.
akruis pushed a commit to akruis/cpython that referenced this pull request
Call Py_DECREF(frame) with the right recursion_depth.
akruis pushed a commit to akruis/cpython that referenced this pull request
Call Py_DECREF(frame) with the right recursion_depth. Add a changelog entry. The actual fix was part of commit cfd51a5.
akruis pushed a commit to akruis/cpython that referenced this pull request
Call Py_DECREF(frame) with the right recursion_depth. (cherry picked from commit e520032)
SonicField added a commit to SonicField/cpython that referenced this pull request
Codifies three protocols developed across the emitAnyCall PURE conversion arc (push 56-59) per pythia python#142/python#141/python#143 + supervisor + theologian authorizations: P8 — Phase 0' Coverage Extension to Perf-Regressing Benchmarks Per pythia python#142 python#1 + supervisor 22:46:24Z + 22:47:40Z. Sentinel-only HIR diff has empirical blind spot to single-bench regressions on unrelated workloads (caught when emitAnyCall push 59 showed int_arith -10% with exception-sentinel HIR-diff PASSING). Procedure: identify 24-bench >5% benches, run Phase 0' HIR-diff on bench source per identified bench (precise scrub, structural diff). Add to gate Step 7 post-processing. P9 — Filesystem-First Cross-Check Before Fabrication HALT Per medic 2026-04-22 build-claim false positive + medic 2026-04-25 22:50:53Z PYTHONJITDUMPFINALHIR false positive against generalist HIR dumps that were filesystem-verified at /tmp + retracted at 22:53:44Z. Procedure: identify implied artifact, ls + stat to confirm existence/mtime, post QUERY (not HALT) if artifact exists, never cite session-log absence as sole evidence. Costs ~30s vs ~5-10min false- positive recovery cycle. P10 — Variance Characterization Before (B) Investigation Per W-EMITANYCALL-INT-ARITH-PERF closure 22:57:29Z + pythia python#143 python#1 amendment 23:21:18Z + supervisor 23:21:51Z. Mirrors agent-memory feedback_falsifier_convergent_negative.md (per-agent reasoning side); P10 codifies team-process side. Procedure (7 steps): identify >5% benches, 3-run targeted re-runs for in-isolation variance, AT LEAST ONE full-24-bench re-run for in-context variance (different statistical populations: page-cache, branch-predictor, allocator history, subprocess-position effects). Closure REQUIRES both isolated AND in-context corroboration; if isolated clean but in-context reproduces delta → real signal in sequence-context layer (cold-start/page-cache), not at conversion layer. Pythia python#143 python#4 caught these 3 protocols as 'LANDED in spec but uncommitted at HEAD 0810be4 — exist only in working tree, not yet history.' This commit closes that gap: protocols now in git history before being cited as canonical (CC3 codification-on-authoring rule). Spec doc: P1-P10 + 3 cross-cutting (CC1/CC2/CC3) + paired empirical controls (PhxMem positive / HirType negative). Bundle target: push 60 if Alex authorizes (A)/(B)/(C); separate codification push if Alex direction is delayed >2hr per supervisor 23:21:51Z.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters