[Python-checkins] cpython: #17032: The "global" in the "NameError: global name 'x' is not defined" error

ezio.melotti python-checkins at python.org
Sun Mar 3 14:13:17 CET 2013


http://hg.python.org/cpython/rev/f1d3fbcd837d
changeset:   82459:f1d3fbcd837d
parent:      82457:1c71882938eb
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Sun Mar 03 15:12:44 2013 +0200
summary:
  #17032: The "global" in the "NameError: global name 'x' is not defined" error message has been removed.  Patch by Ram Rachum.

files:
  Lib/test/test_keywordonlyarg.py |  4 ++--
  Misc/ACKS                       |  1 +
  Misc/NEWS                       |  3 +++
  Python/ceval.c                  |  8 +++-----
  4 files changed, 9 insertions(+), 7 deletions(-)


diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py
--- a/Lib/test/test_keywordonlyarg.py
+++ b/Lib/test/test_keywordonlyarg.py
@@ -182,10 +182,10 @@
         with self.assertRaises(NameError) as err:
             def f(v=a, x=b, *, y=c, z=d):
                 pass
-        self.assertEqual(str(err.exception), "global name 'b' is not defined")
+        self.assertEqual(str(err.exception), "name 'b' is not defined")
         with self.assertRaises(NameError) as err:
             f = lambda v=a, x=b, *, y=c, z=d: None
-        self.assertEqual(str(err.exception), "global name 'b' is not defined")
+        self.assertEqual(str(err.exception), "name 'b' is not defined")
 
 
 def test_main():
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -969,6 +969,7 @@
 Pierre Quentel
 Brian Quinlan
 Anders Qvist
+Ram Rachum
 Jérôme Radix
 Burton Radons
 Jeff Ramnani
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #17032: The "global" in the "NameError: global name 'x' is not defined"
+  error message has been removed.  Patch by Ram Rachum.
+
 - Issue #17223: array module: Fix a crasher when converting an array containing
   invalid characters (outside range [U+0000; U+10ffff]) to Unicode:
   repr(array), str(array) and array.tounicode(). Patch written by Manuel Jacob.
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -142,8 +142,6 @@
 
 #define NAME_ERROR_MSG \
     "name '%.200s' is not defined"
-#define GLOBAL_NAME_ERROR_MSG \
-    "global name '%.200s' is not defined"
 #define UNBOUNDLOCAL_ERROR_MSG \
     "local variable '%.200s' referenced before assignment"
 #define UNBOUNDFREE_ERROR_MSG \
@@ -2140,7 +2138,7 @@
             err = PyDict_DelItem(f->f_globals, name);
             if (err != 0) {
                 format_exc_check_arg(
-                    PyExc_NameError, GLOBAL_NAME_ERROR_MSG, name);
+                    PyExc_NameError, NAME_ERROR_MSG, name);
                 goto error;
             }
             DISPATCH();
@@ -2208,7 +2206,7 @@
                 if (v == NULL) {
                     if (!PyErr_Occurred())
                         format_exc_check_arg(PyExc_NameError,
-                                             GLOBAL_NAME_ERROR_MSG, name);
+                                             NAME_ERROR_MSG, name);
                     goto error;
                 }
                 Py_INCREF(v);
@@ -2222,7 +2220,7 @@
                         if (PyErr_ExceptionMatches(PyExc_KeyError))
                             format_exc_check_arg(
                                         PyExc_NameError,
-                                        GLOBAL_NAME_ERROR_MSG, name);
+                                        NAME_ERROR_MSG, name);
                         goto error;
                     }
                 }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list