Skip to content

Commit 0dafc78

Browse files
authored
gh-102778: update documentation of PyErr_PrintEx and traceback.print_last() regarding sys.last_exc (#105190)
1 parent 2f5c1ae commit 0dafc78

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Doc/c-api/exceptions.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ Printing and clearing
6060
Call this function **only** when the error indicator is set. Otherwise it
6161
will cause a fatal error!
6262
63-
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
64-
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
65-
type, value and traceback of the printed exception, respectively.
63+
If *set_sys_last_vars* is nonzero, the variable :data:`sys.last_exc` is
64+
set to the printed exception. For backwards compatibility, the
65+
deprecated variables :data:`sys.last_type`, :data:`sys.last_value` and
66+
:data:`sys.last_traceback` are also set to the type, value and traceback
67+
of this exception, respectively.
68+
69+
.. versionchanged:: 3.12
70+
The setting of :data:`sys.last_exc` was added.
6671
6772
6873
.. c:function:: void PyErr_Print()

Doc/library/traceback.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,9 @@ The module defines the following functions:
8686

8787
.. function:: print_last(limit=None, file=None, chain=True)
8888

89-
This is a shorthand for ``print_exception(sys.last_type, sys.last_value,
90-
sys.last_traceback, limit, file, chain)``. In general it will work only
91-
after an exception has reached an interactive prompt (see
92-
:data:`sys.last_type`).
89+
This is a shorthand for ``print_exception(sys.last_exc, limit, file,
90+
chain)``. In general it will work only after an exception has reached
91+
an interactive prompt (see :data:`sys.last_exc`).
9392

9493

9594
.. function:: print_stack(f=None, limit=None, file=None)

0 commit comments

Comments
 (0)