if (alist != NULL) {
if (!PyTuple_Check(alist)) {
if (!PySequence_Check(alist)) {
- PyErr_SetString(PyExc_TypeError,
- "apply() arg 2 must be a sequence");
+ PyErr_Format(PyExc_TypeError,
+ "apply() arg 2 expect sequence, found %s",
+ alist->ob_type->tp_name);
return NULL;
}
t = PySequence_Tuple(alist);
}
}
if (kwdict != NULL && !PyDict_Check(kwdict)) {
- PyErr_SetString(PyExc_TypeError,
- "apply() arg 3 must be a dictionary");
+ PyErr_Format(PyExc_TypeError,
+ "apply() arg 3 expected dictionary, found %s",
+ kwdict->ob_type->tp_name);
goto finally;
}
retval = PyEval_CallObjectWithKeywords(func, alist, kwdict);
#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 */
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);
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)
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);
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);