bpo-23915: update and elucidate documentation of with_traceback (GH-2… · python/cpython@c590c23 (original) (raw)

Original file line number Diff line number Diff line change
@@ -90,8 +90,13 @@ The following exceptions are used mostly as base classes for other exceptions.
90 90 .. method:: with_traceback(tb)
91 91
92 92 This method sets *tb* as the new traceback for the exception and returns
93 - the exception object. It is usually used in exception handling code like
94 - this::
93 + the exception object. It was more commonly used before the exception
94 + chaining features of :pep:`3134` became available. The following example
95 + shows how we can convert an instance of ``SomeException`` into an
96 + instance of ``OtherException`` while preserving the traceback. Once
97 + raised, the current frame is pushed onto the traceback of the
98 + ``OtherException``, as would have happened to the traceback of the
99 + original ``SomeException`` had we allowed it to propagate to the caller.
95 100
96 101 try:
97 102 ...