2020
2121#include <ctype.h>
2222
23+ #define REPR (O ) PyString_AS_STRING(PyObject_Repr(O))
24+
2325/* Turn this on if your compiler chokes on the big switch: */
2426/* #define CASE_TOO_BIG 1 */
2527
@@ -1438,8 +1440,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
14381440 w = GETNAMEV (oparg );
14391441 v = POP ();
14401442 if ((x = f -> f_locals ) == NULL ) {
1441- PyErr_SetString (PyExc_SystemError ,
1442- "no locals" );
1443+ PyErr_Format (PyExc_SystemError ,
1444+ "no locals found when storing %s" ,
1445+ REPR (w ));
14431446 break ;
14441447 }
14451448 err = PyDict_SetItem (x , w , v );
@@ -1449,8 +1452,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
14491452 case DELETE_NAME :
14501453 w = GETNAMEV (oparg );
14511454 if ((x = f -> f_locals ) == NULL ) {
1452- PyErr_SetString (PyExc_SystemError ,
1453- "no locals" );
1455+ PyErr_Format (PyExc_SystemError ,
1456+ "no locals when deleting %s" ,
1457+ REPR (w ));
14541458 break ;
14551459 }
14561460 if ((err = PyDict_DelItem (x , w )) != 0 )
@@ -1543,8 +1547,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
15431547 case LOAD_NAME :
15441548 w = GETNAMEV (oparg );
15451549 if ((x = f -> f_locals ) == NULL ) {
1546- PyErr_SetString (PyExc_SystemError ,
1547- "no locals" );
1550+ PyErr_Format (PyExc_SystemError ,
1551+ "no locals when loading %s" ,
1552+ REPR (w ));
15481553 break ;
15491554 }
15501555 x = PyDict_GetItem (x , w );
@@ -1716,7 +1721,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
17161721 PyFrame_FastToLocals (f );
17171722 if ((x = f -> f_locals ) == NULL ) {
17181723 PyErr_SetString (PyExc_SystemError ,
1719- "no locals" );
1724+ "no locals found during 'import *' " );
17201725 break ;
17211726 }
17221727 err = import_all_from (x , v );
0 commit comments