diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2012-04-19 12:33:43 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2012-04-19 12:33:43 (GMT) |
commit | aa2efcb0bcb80465cfa7114bb20d99c13be57f1c (patch) | |
tree | c9af5b98cf8d7803c1e86d6b9b7104a6a569a77a /Modules | |
parent | e27b3608ef04daa5e27029c329ad426782c9670c (diff) | |
download | cpython-aa2efcb0bcb80465cfa7114bb20d99c13be57f1c.zip cpython-aa2efcb0bcb80465cfa7114bb20d99c13be57f1c.tar.gz cpython-aa2efcb0bcb80465cfa7114bb20d99c13be57f1c.tar.bz2 |
Issue #14098: New functions PyErr_GetExcInfo and PyErr_SetExcInfo.
Patch by Stefan Behnel.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 093f205..ec52a09 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1639,6 +1639,29 @@ raise_exception(PyObject *self, PyObject *args) return NULL; } +static PyObject * +test_set_exc_info(PyObject *self, PyObject *args) +{ + PyObject *orig_exc; + PyObject *new_type, *new_value, *new_tb; + PyObject *type, *value, *tb; + if (!PyArg_ParseTuple(args, "OOO:test_set_exc_info", + &new_type, &new_value, &new_tb)) + return NULL; + + PyErr_GetExcInfo(&type, &value, &tb); + + Py_INCREF(new_type); + Py_INCREF(new_value); + Py_INCREF(new_tb); + PyErr_SetExcInfo(new_type, new_value, new_tb); + + orig_exc = PyTuple_Pack(3, type ? type : Py_None, value ? value : Py_None, tb ? tb : Py_None); + Py_XDECREF(type); + Py_XDECREF(value); + Py_XDECREF(tb); + return orig_exc; +} static int test_run_counter = 0; @@ -2471,6 +2494,7 @@ static PyMethodDef TestMethods[] = { #endif {"traceback_print", traceback_print, METH_VARARGS}, {"exception_print", exception_print, METH_VARARGS}, + {"set_exc_info", test_set_exc_info, METH_VARARGS}, {"argparsing", argparsing, METH_VARARGS}, {"code_newempty", code_newempty, METH_VARARGS}, {"make_exception_with_doc", (PyCFunction)make_exception_with_doc, |