[Python-checkins] python/dist/src/Python ceval.c,2.397,2.398
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sat Jun 5 02:16:25 EDT 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20107
Modified Files:
ceval.c
Log Message:
SF bug #963956: Bad error mesage when subclassing a module
Add a more informative message for the common user mistake of subclassing
from a module name rather than another class (i.e. random instead of
random.random).
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.397
retrieving revision 2.398
diff -C2 -d -r2.397 -r2.398
*** ceval.c 1 Jun 2004 15:22:42 -0000 2.397
--- ceval.c 5 Jun 2004 06:16:22 -0000 2.398
***************
*** 3923,3926 ****
--- 3923,3935 ----
result = PyObject_CallFunction(metaclass, "OOO", name, bases, methods);
Py_DECREF(metaclass);
+ if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {
+ /* A type error here likely means that the user passed
+ in a base that was not a class (such the random module
+ instead of the random.random type). Help them out with
+ a more informative error message */
+ PyErr_SetString(PyExc_TypeError,
+ "Error when calling the metaclass.\n" \
+ "Make sure the base arguments are valid.");
+ }
return result;
}
More information about the Python-checkins
mailing list