]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42179: Doc/tutorial: Remove mention of __cause__ (GH-23162)
authorInada Naoki <songofacandy@gmail.com>
Fri, 6 Nov 2020 02:45:01 +0000 (11:45 +0900)
committerGitHub <noreply@github.com>
Fri, 6 Nov 2020 02:45:01 +0000 (11:45 +0900)
Doc/tutorial/errors.rst

index 0ce96466e8c286913db59b8be607568a4bb3f18f..efe44da3043c5e2faffcddd0aeb200c1ec5c8393 100644 (file)
@@ -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: