[Python-checkins] gh-102778: update documentation of PyErr_PrintEx and traceback.print_last() regarding sys.last_exc (#105190)
iritkatriel
webhook-mailer at python.org
Fri Jun 2 12:01:54 EDT 2023
https://github.com/python/cpython/commit/0dafc785ee6629dbcb9bec6f7aee43a56cd0b26e
commit: 0dafc785ee6629dbcb9bec6f7aee43a56cd0b26e
branch: main
author: Irit Katriel <1055913+iritkatriel at users.noreply.github.com>
committer: iritkatriel <1055913+iritkatriel at users.noreply.github.com>
date: 2023-06-02T17:01:46+01:00
summary:
gh-102778: update documentation of PyErr_PrintEx and traceback.print_last() regarding sys.last_exc (#105190)
files:
M Doc/c-api/exceptions.rst
M Doc/library/traceback.rst
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index dc73ad815796..1694aa2db9c9 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -60,9 +60,14 @@ Printing and clearing
Call this function **only** when the error indicator is set. Otherwise it
will cause a fatal error!
- If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
- :data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
- type, value and traceback of the printed exception, respectively.
+ If *set_sys_last_vars* is nonzero, the variable :data:`sys.last_exc` is
+ set to the printed exception. For backwards compatibility, the
+ 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()
diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst
index 9a04b56947a1..58f47818fcec 100644
--- a/Doc/library/traceback.rst
+++ b/Doc/library/traceback.rst
@@ -86,10 +86,9 @@ The module defines the following functions:
.. function:: print_last(limit=None, file=None, chain=True)
- This is a shorthand for ``print_exception(sys.last_type, sys.last_value,
- sys.last_traceback, limit, file, chain)``. In general it will work only
- after an exception has reached an interactive prompt (see
- :data:`sys.last_type`).
+ This is a shorthand for ``print_exception(sys.last_exc, limit, file,
+ chain)``. In general it will work only after an exception has reached
+ an interactive prompt (see :data:`sys.last_exc`).
.. function:: print_stack(f=None, limit=None, file=None)
More information about the Python-checkins
mailing list