Skip to content

Commit bde33e4

Browse files
authored
bpo-42179: Doc/tutorial: Remove mention of __cause__ (GH-23162)
1 parent 91e9379 commit bde33e4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Doc/tutorial/errors.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,15 @@ Exception Chaining
273273
==================
274274

275275
The :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

281281
This 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

Comments
 (0)