gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException (GH-30531)

This commit is contained in:
Irit Katriel 2022-04-15 19:57:47 +01:00 committed by GitHub
parent c06a4ffe81
commit 5d421d7342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 141 additions and 24 deletions

View file

@ -381,19 +381,12 @@ always available.
.. function:: exception()
This function returns the exception instance that is currently being
handled. This exception is specific both to the current thread and
to the current stack frame. If the current stack frame is not handling
an exception, the exception is taken from the calling stack frame, or its
caller, and so on until a stack frame is found that is handling an
exception. Here, "handling an exception" is defined as "executing an
except clause." For any stack frame, only the exception being currently
handled is accessible.
This function, when called while an exception handler is executing (such as
an ``except`` or ``except*`` clause), returns the exception instance that
was caught by this handler. When exception handlers are nested within one
another, only the exception handled by the innermost handler is accessible.
.. index:: object: traceback
If no exception is being handled anywhere on the stack, ``None`` is
returned.
If no exception handler is executing, this function returns ``None``.
.. versionadded:: 3.11