implement chained exception tracebacks

patch from Antoine Pitrou #3112
This commit is contained in:
Benjamin Peterson 2008-07-15 15:32:09 +00:00
parent 9bab65c259
commit e65282114e
10 changed files with 449 additions and 133 deletions

View file

@ -951,6 +951,26 @@ traceback_print(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
/* To test the format of exceptions as printed out. */
static PyObject *
exception_print(PyObject *self, PyObject *args)
{
PyObject *value;
PyObject *tb;
if (!PyArg_ParseTuple(args, "O:exception_print",
&value))
return NULL;
tb = PyException_GetTraceback(value);
PyErr_Display((PyObject *) Py_TYPE(value), value, tb);
Py_XDECREF(tb);
Py_RETURN_NONE;
}
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
{"test_config", (PyCFunction)test_config, METH_NOARGS},
@ -995,6 +1015,7 @@ static PyMethodDef TestMethods[] = {
{"profile_int", profile_int, METH_NOARGS},
#endif
{"traceback_print", traceback_print, METH_VARARGS},
{"exception_print", exception_print, METH_VARARGS},
{NULL, NULL} /* sentinel */
};