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 /Doc/c-api | |
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 'Doc/c-api')
-rw-r--r-- | Doc/c-api/exceptions.rst | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 877249b..441dade 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -129,6 +129,41 @@ in various ways. There is a separate error indicator for each thread. exception state. +.. c:function:: void PyErr_GetExcInfo(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback) + + Retrieve the exception info, as known from ``sys.exc_info()``. This refers + to an exception that was already caught, not to an exception that was + freshly raised. Returns new references for the three objects, any of which + may be *NULL*. Does not modify the exception info state. + + .. note:: + + This function is not normally used by code that wants to handle exceptions. + Rather, it can be used when code needs to save and restore the exception + state temporarily. Use :c:func:`PyErr_SetExcInfo` to restore or clear the + exception state. + +.. versionadded:: 3.3 + + +.. c:function:: void PyErr_SetExcInfo(PyObject *type, PyObject *value, PyObject *traceback) + + Set the exception info, as known from ``sys.exc_info()``. This refers + to an exception that was already caught, not to an exception that was + freshly raised. This function steals the references of the arguments. + To clear the exception state, pass *NULL* for all three arguments. + For general rules about the three arguments, see :c:func:`PyErr_Restore`. + + .. note:: + + This function is not normally used by code that wants to handle exceptions. + Rather, it can be used when code needs to save and restore the exception + state temporarily. Use :c:func:`PyErr_GetExcInfo` to read the exception + state. + +.. versionadded:: 3.3 + + .. c:function:: void PyErr_SetString(PyObject *type, const char *message) This is the most common way to set the error indicator. The first argument |