mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
d8efc14951
commit
3430c55417
3 changed files with 12 additions and 4 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue