summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2020-01-13 16:30:14 (GMT)
committerVictor Stinner <vstinner@python.org>2020-01-13 16:30:14 (GMT)
commit3430c55417f59078ac397c343894a3ee82a39624 (patch)
treed3af476d850ca05ea37130eb7e22c0229cb13612 /Python/errors.c
parentd8efc1495194228c3a4cd472200275d6491d8e2d (diff)
downloadcpython-3430c55417f59078ac397c343894a3ee82a39624.zip
cpython-3430c55417f59078ac397c343894a3ee82a39624.tar.gz
cpython-3430c55417f59078ac397c343894a3ee82a39624.tar.bz2
bpo-39164: Add private _PyErr_GetExcInfo() function (GH-17752)
This adds a new function named _PyErr_GetExcInfo() that is a variation of the original PyErr_GetExcInfo() taking a PyThreadState as its first argument. That function allows to retrieve the exceptions information of any Python thread -- not only the current one.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/errors.c b/Python/errors.c
index d65707e..cdb4460 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -433,21 +433,27 @@ PyErr_Clear(void)
void
-PyErr_GetExcInfo(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
+_PyErr_GetExcInfo(PyThreadState *tstate,
+ PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
{
- PyThreadState *tstate = _PyThreadState_GET();
-
_PyErr_StackItem *exc_info = _PyErr_GetTopmostException(tstate);
*p_type = exc_info->exc_type;
*p_value = exc_info->exc_value;
*p_traceback = exc_info->exc_traceback;
-
Py_XINCREF(*p_type);
Py_XINCREF(*p_value);
Py_XINCREF(*p_traceback);
}
+
+void
+PyErr_GetExcInfo(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
+{
+ PyThreadState *tstate = _PyThreadState_GET();
+ return _PyErr_GetExcInfo(tstate, p_type, p_value, p_traceback);
+}
+
void
PyErr_SetExcInfo(PyObject *p_type, PyObject *p_value, PyObject *p_traceback)
{