Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e74fb2d

Browse filesBrowse files
bpo-42179: Doc/tutorial: Remove mention of __cause__ (GH-23162)
(cherry picked from commit bde33e4) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
1 parent 3997a4e commit e74fb2d
Copy full SHA for e74fb2d

File tree

Expand file treeCollapse file tree

1 file changed

+10
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-9
lines changed

‎Doc/tutorial/errors.rst

Copy file name to clipboardExpand all lines: Doc/tutorial/errors.rst
+10-9Lines changed: 10 additions & 9 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.