From 2157f0429d311e6add84bffe2faf454401852618 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Thu, 1 Jun 2023 12:29:47 +0100 Subject: [PATCH 1/4] gh-102778: update documentation of PyErr_PrintEx regarding sys.last_exc --- Doc/c-api/exceptions.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index dc73ad8157961b..3978b0e59cea36 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 + :data:`sys.last_exc` was added. .. c:function:: void PyErr_Print() From 1d4907bc702448442a997387d4c85602846cc348 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Thu, 1 Jun 2023 12:47:53 +0100 Subject: [PATCH 2/4] traceback module too --- Doc/library/traceback.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index 9a04b56947a1bb..58f47818fcecab 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) From 8f3788f07edfb53aa88cacce0c32a207c3e23ea3 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Thu, 1 Jun 2023 12:50:55 +0100 Subject: [PATCH 3/4] whitespace --- Doc/c-api/exceptions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 3978b0e59cea36..acd91b64286cc3 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -67,7 +67,7 @@ Printing and clearing of this exception, respectively. .. versionchanged:: 3.12 - :data:`sys.last_exc` was added. + :data:`sys.last_exc` was added. .. c:function:: void PyErr_Print() From 00a69362102d1b119d4f6d16460a9122cb097c82 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Fri, 2 Jun 2023 11:21:30 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Terry Jan Reedy --- Doc/c-api/exceptions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index acd91b64286cc3..1694aa2db9c9da 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -67,7 +67,7 @@ Printing and clearing of this exception, respectively. .. versionchanged:: 3.12 - :data:`sys.last_exc` was added. + The setting of :data:`sys.last_exc` was added. .. c:function:: void PyErr_Print()