]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42179: Clarify exception chaining (GH-23160)
authorVladimir <greatvovan@gmail.com>
Wed, 16 Dec 2020 02:47:26 +0000 (18:47 -0800)
committerGitHub <noreply@github.com>
Wed, 16 Dec 2020 02:47:26 +0000 (18:47 -0800)
* Update errors.rst

Clarify exception chaining behaviour and give a reference to the library documentation.

* Update errors.rst

Wording

* Update errors.rst

Spelling

* Update errors.rst

Remove mentioning of special attributes as folks think it's too much for beginners.

Doc/tutorial/errors.rst

index efe44da3043c5e2faffcddd0aeb200c1ec5c8393..4a25861a050e61a475e7410e6f916bb34a9d0774 100644 (file)
@@ -281,17 +281,17 @@ chaining exceptions. For example::
 This can be useful when you are transforming exceptions. For example::
 
     >>> def func():
-    ...     raise IOError
+    ...     raise ConnectionError
     ...
     >>> try:
     ...     func()
-    ... except IOError as exc:
+    ... except ConnectionError as exc:
     ...     raise RuntimeError('Failed to open database') from exc
     ...
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
       File "<stdin>", line 2, in func
-    OSError
+    ConnectionError
     <BLANKLINE>
     The above exception was the direct cause of the following exception:
     <BLANKLINE>
@@ -300,7 +300,7 @@ This can be useful when you are transforming exceptions. For example::
     RuntimeError: Failed to open database
 
 Exception chaining happens automatically when an exception is raised inside an
-:keyword:`except` or :keyword:`finally` section. Exception chaining can be
+:keyword:`except` or :keyword:`finally` section. This can be
 disabled by using ``from None`` idiom:
 
     >>> try: