diff Python/ceval.c @ 16017:7234d7c3c29f legacy-trunk

clearer error messages for apply() and "no locals"
author Jeremy Hylton <jeremy@alum.mit.edu>
date Fri, 19 Jan 2001 03:25:05 +0000
parents 3bc2440427d3
children fd8c7203251f
line wrap: on
line diff
--- a/Python/ceval.c	Fri Jan 19 03:22:48 2001 +0000
+++ b/Python/ceval.c	Fri Jan 19 03:25:05 2001 +0000
@@ -20,6 +20,8 @@
 
 #include <ctype.h>
 
+#define REPR(O) PyString_AS_STRING(PyObject_Repr(O))
+
 /* Turn this on if your compiler chokes on the big switch: */
 /* #define CASE_TOO_BIG 1 */
 
@@ -1438,8 +1440,9 @@
 			w = GETNAMEV(oparg);
 			v = POP();
 			if ((x = f->f_locals) == NULL) {
-				PyErr_SetString(PyExc_SystemError,
-						"no locals");
+				PyErr_Format(PyExc_SystemError,
+					     "no locals found when storing %s",
+					     REPR(w));
 				break;
 			}
 			err = PyDict_SetItem(x, w, v);
@@ -1449,8 +1452,9 @@
 		case DELETE_NAME:
 			w = GETNAMEV(oparg);
 			if ((x = f->f_locals) == NULL) {
-				PyErr_SetString(PyExc_SystemError,
-						"no locals");
+				PyErr_Format(PyExc_SystemError,
+					     "no locals when deleting %s",
+					     REPR(w));
 				break;
 			}
 			if ((err = PyDict_DelItem(x, w)) != 0)
@@ -1543,8 +1547,9 @@
 		case LOAD_NAME:
 			w = GETNAMEV(oparg);
 			if ((x = f->f_locals) == NULL) {
-				PyErr_SetString(PyExc_SystemError,
-						"no locals");
+				PyErr_Format(PyExc_SystemError,
+					     "no locals when loading %s",
+					     REPR(w));
 				break;
 			}
 			x = PyDict_GetItem(x, w);
@@ -1716,7 +1721,7 @@
 			PyFrame_FastToLocals(f);
 			if ((x = f->f_locals) == NULL) {
 				PyErr_SetString(PyExc_SystemError,
-						"no locals");
+					"no locals found during 'import *'");
 				break;
 			}
 			err = import_all_from(x, v);