From ad9811f9f777aba3325f07a18435e86a5b27f875 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Mon, 7 Dec 2020 16:43:40 +0000 Subject: [PATCH 1/3] bpo-23915: update and elucidate documentation of with_traceback --- Doc/library/exceptions.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 8fb25a50e2d404..fd46898fa95c00 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -90,8 +90,13 @@ The following exceptions are used mostly as base classes for other exceptions. .. method:: with_traceback(tb) This method sets *tb* as the new traceback for the exception and returns - the exception object. It is usually used in exception handling code like - this:: + the exception object. It was more commonly used before the exception + chaining features of :pep:`484` became available. The following example + shows how we can convert an instance of ``SomeException`` into an + instance of ``OtherException`` while preserving the traceback. Once + raised, the current frame is pushed unto the traceback of the + ``OtherException``, as would have happened to the traceback of the + original ``SomeException`` had we allowed it to propagate to the caller. try: ... From 1071f280cc8fd6fd2408ca3acb19ce88a2c4bcbf Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Mon, 7 Dec 2020 17:15:41 +0000 Subject: [PATCH 2/3] Update exceptions.rst --- Doc/library/exceptions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index fd46898fa95c00..ed18d04b1b8263 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -94,7 +94,7 @@ The following exceptions are used mostly as base classes for other exceptions. chaining features of :pep:`484` became available. The following example shows how we can convert an instance of ``SomeException`` into an instance of ``OtherException`` while preserving the traceback. Once - raised, the current frame is pushed unto the traceback of the + raised, the current frame is pushed onto the traceback of the ``OtherException``, as would have happened to the traceback of the original ``SomeException`` had we allowed it to propagate to the caller. From 0ec7c45b994f131622734687e34e702cd885ac2a Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 15 Dec 2020 16:33:39 +0000 Subject: [PATCH 3/3] Update Doc/library/exceptions.rst Co-authored-by: Julien Palard --- Doc/library/exceptions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index ed18d04b1b8263..1028213699d637 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -91,7 +91,7 @@ The following exceptions are used mostly as base classes for other exceptions. This method sets *tb* as the new traceback for the exception and returns the exception object. It was more commonly used before the exception - chaining features of :pep:`484` became available. The following example + chaining features of :pep:`3134` became available. The following example shows how we can convert an instance of ``SomeException`` into an instance of ``OtherException`` while preserving the traceback. Once raised, the current frame is pushed onto the traceback of the