diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-07-15 15:32:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-07-15 15:32:09 (GMT) |
commit | e65282114e96efb9e7eee77c57244943b746f6fe (patch) | |
tree | 9daa571b35e287058d54b39bffbc6ca89a843f65 /Modules | |
parent | 9bab65c25928617b2911d2f42d01e5543893ed93 (diff) | |
download | cpython-e65282114e96efb9e7eee77c57244943b746f6fe.zip cpython-e65282114e96efb9e7eee77c57244943b746f6fe.tar.gz cpython-e65282114e96efb9e7eee77c57244943b746f6fe.tar.bz2 |
implement chained exception tracebacks
patch from Antoine Pitrou #3112
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index d8bb835..45494dd 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -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 */ }; |