@@ -378,26 +378,41 @@ always available.
378378 .. versionadded :: 3.8
379379 __unraisablehook__
380380
381+
382+ .. function :: exception()
383+
384+ This function returns the exception instance that is currently being
385+ handled. This exception is specific both to the current thread and
386+ to the current stack frame. If the current stack frame is not handling
387+ an exception, the exception is taken from the calling stack frame, or its
388+ caller, and so on until a stack frame is found that is handling an
389+ exception. Here, "handling an exception" is defined as "executing an
390+ except clause." For any stack frame, only the exception being currently
391+ handled is accessible.
392+
393+ .. index :: object: traceback
394+
395+ If no exception is being handled anywhere on the stack, ``None `` is
396+ returned.
397+
398+ .. versionadded :: 3.11
399+
400+
381401.. function :: exc_info()
382402
383- This function returns a tuple of three values that give information about the
384- exception that is currently being handled. The information returned is specific
385- both to the current thread and to the current stack frame. If the current stack
386- frame is not handling an exception, the information is taken from the calling
387- stack frame, or its caller, and so on until a stack frame is found that is
388- handling an exception. Here, "handling an exception" is defined as "executing
389- an except clause." For any stack frame, only information about the exception
390- being currently handled is accessible .
403+ This function returns the old-style representation of the handled
404+ exception. If an exception `` e `` is currently handled (so
405+ :func: ` exception ` would return `` e ``), :func: ` exc_info ` returns the
406+ tuple `` (type(e), e, e.__traceback__) ``.
407+ That is, a tuple containing the type of the exception (a subclass of
408+ :exc: ` BaseException `), the exception itself, and a :ref: ` traceback
409+ object <traceback-objects>` which typically encapsulates the call
410+ stack at the point where the exception last occurred .
391411
392412 .. index :: object: traceback
393413
394- If no exception is being handled anywhere on the stack, a tuple containing
395- three ``None `` values is returned. Otherwise, the values returned are
396- ``(type, value, traceback) ``. Their meaning is: *type * gets the type of the
397- exception being handled (a subclass of :exc: `BaseException `); *value * gets
398- the exception instance (an instance of the exception type); *traceback * gets
399- a :ref: `traceback object <traceback-objects >` which typically encapsulates
400- the call stack at the point where the exception last occurred.
414+ If no exception is being handled anywhere on the stack, this function
415+ return a tuple containing three ``None `` values.
401416
402417 .. versionchanged :: 3.11
403418 The ``type `` and ``traceback `` fields are now derived from the ``value ``
0 commit comments