@@ -273,15 +273,15 @@ Exception Chaining
273273==================
274274
275275The :keyword: `raise ` statement allows an optional :keyword: `from ` which enables
276- chaining exceptions by setting the ``__cause__ `` attribute of the raised
277- exception. For example::
276+ chaining exceptions. For example::
278277
279- raise RuntimeError from OSError
278+ # exc must be exception instance or None.
279+ raise RuntimeError from exc
280280
281281This can be useful when you are transforming exceptions. For example::
282282
283283 >>> def func():
284- ... raise IOError
284+ ... raise IOError
285285 ...
286286 >>> try:
287287 ... func()
@@ -297,12 +297,11 @@ This can be useful when you are transforming exceptions. For example::
297297 <BLANKLINE>
298298 Traceback (most recent call last):
299299 File "<stdin>", line 4, in <module>
300- RuntimeError
300+ RuntimeError: Failed to open database
301301
302- The expression following the :keyword: `from ` must be either an exception or
303- ``None ``. Exception chaining happens automatically when an exception is raised
304- inside an exception handler or :keyword: `finally ` section. Exception chaining
305- can be disabled by using ``from None `` idiom:
302+ Exception chaining happens automatically when an exception is raised inside an
303+ :keyword: `except ` or :keyword: `finally ` section. Exception chaining can be
304+ disabled by using ``from None `` idiom:
306305
307306 >>> try :
308307 ... open (' database.sqlite' )
@@ -313,6 +312,8 @@ can be disabled by using ``from None`` idiom:
313312 File "<stdin>", line 4, in <module>
314313 RuntimeError
315314
315+ For more information about chaining mechanics, see :ref: `bltin-exceptions `.
316+
316317
317318.. _tut-userexceptions :
318319
0 commit comments