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 /Python | |
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 'Python')
-rw-r--r-- | Python/errors.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c index 36ab3d8..626b16e 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -320,6 +320,39 @@ PyErr_Clear(void) PyErr_Restore(NULL, NULL, NULL); } +void +PyErr_GetExcInfo(PyObject **p_type, PyObject **p_value, PyObject **p_traceback) +{ + PyThreadState *tstate = PyThreadState_GET(); + + *p_type = tstate->exc_type; + *p_value = tstate->exc_value; + *p_traceback = tstate->exc_traceback; + + Py_XINCREF(*p_type); + Py_XINCREF(*p_value); + Py_XINCREF(*p_traceback); +} + +void +PyErr_SetExcInfo(PyObject *p_type, PyObject *p_value, PyObject *p_traceback) +{ + PyObject *oldtype, *oldvalue, *oldtraceback; + PyThreadState *tstate = PyThreadState_GET(); + + oldtype = tstate->exc_type; + oldvalue = tstate->exc_value; + oldtraceback = tstate->exc_traceback; + + tstate->exc_type = p_type; + tstate->exc_value = p_value; + tstate->exc_traceback = p_traceback; + + Py_XDECREF(oldtype); + Py_XDECREF(oldvalue); + Py_XDECREF(oldtraceback); +} + /* Convenience functions to set a type error exception and return 0 */ int |