bpo-42179: Doc/tutorial: Remove mention of __cause__ (GH-23162)

(cherry picked from commit bde33e428d)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
This commit is contained in:
Miss Islington (bot) 2020-11-05 19:05:57 -08:00 committed by GitHub
parent 3997a4e6bc
commit e74fb2d766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -273,10 +273,10 @@ Exception Chaining
================== ==================
The :keyword:`raise` statement allows an optional :keyword:`from` which enables The :keyword:`raise` statement allows an optional :keyword:`from` which enables
chaining exceptions by setting the ``__cause__`` attribute of the raised chaining exceptions. For example::
exception. For example::
raise RuntimeError from OSError # exc must be exception instance or None.
raise RuntimeError from exc
This can be useful when you are transforming exceptions. For example:: This can be useful when you are transforming exceptions. For example::
@ -297,12 +297,11 @@ This can be useful when you are transforming exceptions. For example::
<BLANKLINE> <BLANKLINE>
Traceback (most recent call last): Traceback (most recent call last):
File "<stdin>", line 4, in <module> File "<stdin>", line 4, in <module>
RuntimeError RuntimeError: Failed to open database
The expression following the :keyword:`from` must be either an exception or Exception chaining happens automatically when an exception is raised inside an
``None``. Exception chaining happens automatically when an exception is raised :keyword:`except` or :keyword:`finally` section. Exception chaining can be
inside an exception handler or :keyword:`finally` section. Exception chaining disabled by using ``from None`` idiom:
can be disabled by using ``from None`` idiom:
>>> try: >>> try:
... open('database.sqlite') ... open('database.sqlite')
@ -313,6 +312,8 @@ can be disabled by using ``from None`` idiom:
File "<stdin>", line 4, in <module> File "<stdin>", line 4, in <module>
RuntimeError RuntimeError
For more information about chaining mechanics, see :ref:`bltin-exceptions`.
.. _tut-userexceptions: .. _tut-userexceptions: