]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-17792: more accurate error message for unbound variable access exceptions (GH...
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Wed, 2 Jun 2021 13:09:04 +0000 (14:09 +0100)
committerGitHub <noreply@github.com>
Wed, 2 Jun 2021 13:09:04 +0000 (14:09 +0100)
Misc/NEWS.d/next/Core and Builtins/2021-03-22-17-50-30.bpo-17792._zssjS.rst [new file with mode: 0644]
Python/ceval.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-03-22-17-50-30.bpo-17792._zssjS.rst b/Misc/NEWS.d/next/Core and Builtins/2021-03-22-17-50-30.bpo-17792._zssjS.rst
new file mode 100644 (file)
index 0000000..768cbf1
--- /dev/null
@@ -0,0 +1 @@
+More accurate error messages for access of unbound locals or free vars.
index 3bbcfe9c237d881a5b756fd75cba51aca08dae2e..4dff7bd2df9834a3c3c1ab697c7c13c0b83d1235 100644 (file)
@@ -101,10 +101,10 @@ static int get_exception_handler(PyCodeObject *, int, int*, int*, int*);
 #define NAME_ERROR_MSG \
     "name '%.200s' is not defined"
 #define UNBOUNDLOCAL_ERROR_MSG \
-    "local variable '%.200s' referenced before assignment"
+    "cannot access local variable '%s' where it is not associated with a value"
 #define UNBOUNDFREE_ERROR_MSG \
-    "free variable '%.200s' referenced before assignment" \
-    " in enclosing scope"
+    "cannot access free variable '%s' where it is not associated with a" \
+    " value in enclosing scope"
 
 /* Dynamic execution profile */
 #ifdef DYNAMIC_EXECUTION_PROFILE