diff options
author | Julien Danjou <julien@danjou.info> | 2020-11-02 14:16:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 14:16:25 (GMT) |
commit | 64366fa9b3ba71b8a503a8719eff433f4ea49eb9 (patch) | |
tree | 8aa6d76484553d2f29bfe5d03709a86c0abe547f /Python/sysmodule.c | |
parent | 3d86d090dcbbdfdd3e5a5951cab30612d6131222 (diff) | |
download | cpython-64366fa9b3ba71b8a503a8719eff433f4ea49eb9.zip cpython-64366fa9b3ba71b8a503a8719eff433f4ea49eb9.tar.gz cpython-64366fa9b3ba71b8a503a8719eff433f4ea49eb9.tar.bz2 |
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.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 749b964..945e639 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1838,6 +1838,21 @@ sys__current_frames_impl(PyObject *module) } /*[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 func: object @@ -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 |