mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
[3.12] gh-102778: update documentation of PyErr_PrintEx and traceback.print_last() regarding sys.last_exc (GH-105190) (#105246)
gh-102778: update documentation of PyErr_PrintEx and traceback.print_last() regarding sys.last_exc (GH-105190)
(cherry picked from commit 0dafc785ee
)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
parent
103ae4e36e
commit
00fe6186cb
2 changed files with 11 additions and 7 deletions
|
@ -60,9 +60,14 @@ Printing and clearing
|
||||||
Call this function **only** when the error indicator is set. Otherwise it
|
Call this function **only** when the error indicator is set. Otherwise it
|
||||||
will cause a fatal error!
|
will cause a fatal error!
|
||||||
|
|
||||||
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
|
If *set_sys_last_vars* is nonzero, the variable :data:`sys.last_exc` is
|
||||||
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
|
set to the printed exception. For backwards compatibility, the
|
||||||
type, value and traceback of the printed exception, respectively.
|
deprecated variables :data:`sys.last_type`, :data:`sys.last_value` and
|
||||||
|
:data:`sys.last_traceback` are also set to the type, value and traceback
|
||||||
|
of this exception, respectively.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.12
|
||||||
|
The setting of :data:`sys.last_exc` was added.
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: void PyErr_Print()
|
.. c:function:: void PyErr_Print()
|
||||||
|
|
|
@ -86,10 +86,9 @@ The module defines the following functions:
|
||||||
|
|
||||||
.. function:: print_last(limit=None, file=None, chain=True)
|
.. function:: print_last(limit=None, file=None, chain=True)
|
||||||
|
|
||||||
This is a shorthand for ``print_exception(sys.last_type, sys.last_value,
|
This is a shorthand for ``print_exception(sys.last_exc, limit, file,
|
||||||
sys.last_traceback, limit, file, chain)``. In general it will work only
|
chain)``. In general it will work only after an exception has reached
|
||||||
after an exception has reached an interactive prompt (see
|
an interactive prompt (see :data:`sys.last_exc`).
|
||||||
:data:`sys.last_type`).
|
|
||||||
|
|
||||||
|
|
||||||
.. function:: print_stack(f=None, limit=None, file=None)
|
.. function:: print_stack(f=None, limit=None, file=None)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue