comparison Python/errors.c @ 37871:a47117fa3ca8

Fix (and add test for) missing check for BaseException subclasses in the C API.
author Thomas Wouters <thomas@python.org>
date Thu, 20 Apr 2006 22:42:37 +0000
parents 49c6eb688906
children f731859e9b3b
comparison
equal deleted inserted replaced
37870:c4341e6c6a03 37871:a47117fa3ca8
45 } 45 }
46 46
47 void 47 void
48 PyErr_SetObject(PyObject *exception, PyObject *value) 48 PyErr_SetObject(PyObject *exception, PyObject *value)
49 { 49 {
50 if (exception != NULL &&
51 !PyExceptionClass_Check(exception)) {
52 PyObject *excstr = PyObject_Repr(exception);
53 PyErr_Format(PyExc_SystemError,
54 "exception %s not a BaseException subclass",
55 PyString_AS_STRING(excstr));
56 Py_DECREF(excstr);
57 return;
58 }
50 Py_XINCREF(exception); 59 Py_XINCREF(exception);
51 Py_XINCREF(value); 60 Py_XINCREF(value);
52 PyErr_Restore(exception, value, (PyObject *)NULL); 61 PyErr_Restore(exception, value, (PyObject *)NULL);
53 } 62 }
54 63