mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
bpo-41435: Add sys._current_exceptions() function (GH-21689)
This adds a new function named sys._current_exceptions() which is equivalent ot sys._current_frames() except that it returns the exceptions currently handled by other threads. It is equivalent to calling sys.exc_info() for each running thread.
This commit is contained in:
parent
3d86d090dc
commit
64366fa9b3
7 changed files with 185 additions and 1 deletions
|
@ -1837,6 +1837,21 @@ sys__current_frames_impl(PyObject *module)
|
|||
return _PyThread_CurrentFrames();
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
sys._current_exceptions
|
||||
|
||||
Return a dict mapping each thread's identifier to its current raised exception.
|
||||
|
||||
This function should be used for specialized purposes only.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
sys__current_exceptions_impl(PyObject *module)
|
||||
/*[clinic end generated code: output=2ccfd838c746f0ba input=0e91818fbf2edc1f]*/
|
||||
{
|
||||
return _PyThread_CurrentExceptions();
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
sys.call_tracing
|
||||
|
||||
|
@ -1953,6 +1968,7 @@ static PyMethodDef sys_methods[] = {
|
|||
METH_FASTCALL | METH_KEYWORDS, breakpointhook_doc},
|
||||
SYS__CLEAR_TYPE_CACHE_METHODDEF
|
||||
SYS__CURRENT_FRAMES_METHODDEF
|
||||
SYS__CURRENT_EXCEPTIONS_METHODDEF
|
||||
SYS_DISPLAYHOOK_METHODDEF
|
||||
SYS_EXC_INFO_METHODDEF
|
||||
SYS_EXCEPTHOOK_METHODDEF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue