summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-11-06 03:05:57 (GMT)
committerGitHub <noreply@github.com>2020-11-06 03:05:57 (GMT)
commite74fb2d7666eea43ad738528a565bb56bc88c28d (patch)
tree32f57db6e945a0fc226b6b91eee38dbc7ae01871 /Doc
parent3997a4e6bca18c7f220d6212ef1e86d8aa9c7aee (diff)
downloadcpython-e74fb2d7666eea43ad738528a565bb56bc88c28d.zip
cpython-e74fb2d7666eea43ad738528a565bb56bc88c28d.tar.gz
cpython-e74fb2d7666eea43ad738528a565bb56bc88c28d.tar.bz2
bpo-42179: Doc/tutorial: Remove mention of __cause__ (GH-23162)
(cherry picked from commit bde33e428d5b5f88ec7667598fd27d1091840537) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/tutorial/errors.rst19
1 files changed, 10 insertions, 9 deletions
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index 0ce9646..efe44da 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -273,15 +273,15 @@ Exception Chaining
==================
The :keyword:`raise` statement allows an optional :keyword:`from` which enables
-chaining exceptions by setting the ``__cause__`` attribute of the raised
-exception. For example::
+chaining exceptions. 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::
>>> def func():
- ... raise IOError
+ ... raise IOError
...
>>> try:
... func()
@@ -297,12 +297,11 @@ This can be useful when you are transforming exceptions. For example::
<BLANKLINE>
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
- RuntimeError
+ RuntimeError: Failed to open database
-The expression following the :keyword:`from` must be either an exception or
-``None``. Exception chaining happens automatically when an exception is raised
-inside an exception handler or :keyword:`finally` section. Exception chaining
-can be disabled by using ``from None`` idiom:
+Exception chaining happens automatically when an exception is raised inside an
+:keyword:`except` or :keyword:`finally` section. Exception chaining can be
+disabled by using ``from None`` idiom:
>>> try:
... open('database.sqlite')
@@ -313,6 +312,8 @@ can be disabled by using ``from None`` idiom:
File "<stdin>", line 4, in <module>
RuntimeError
+For more information about chaining mechanics, see :ref:`bltin-exceptions`.
+
.. _tut-userexceptions: