Skip to content

Commit 7b1f527

Browse files
authored
bpo-17792: more accurate error message for unbound variable access exceptions (GH-24976)
1 parent 1a8c778 commit 7b1f527

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
More accurate error messages for access of unbound locals or free vars.

Python/ceval.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ static int get_exception_handler(PyCodeObject *, int, int*, int*, int*);
101101
#define NAME_ERROR_MSG \
102102
"name '%.200s' is not defined"
103103
#define UNBOUNDLOCAL_ERROR_MSG \
104-
"local variable '%.200s' referenced before assignment"
104+
"cannot access local variable '%s' where it is not associated with a value"
105105
#define UNBOUNDFREE_ERROR_MSG \
106-
"free variable '%.200s' referenced before assignment" \
107-
" in enclosing scope"
106+
"cannot access free variable '%s' where it is not associated with a" \
107+
" value in enclosing scope"
108108

109109
/* Dynamic execution profile */
110110
#ifdef DYNAMIC_EXECUTION_PROFILE

0 commit comments

Comments
 (0)