[Python-checkins] bpo-42179: Clarify exception chaining (GH-23160)

willingc webhook-mailer at python.org
Tue Dec 15 21:47:36 EST 2020

commit: 3f9fe23c05280dc5736c07bb0e968cdaf8c503d0
branch: master
author: Vladimir <greatvovan at gmail.com>
committer: willingc <carolcode at willingconsulting.com>
date: 2020-12-15T18:47:26-08:00

bpo-42179: Clarify exception chaining (GH-23160)

* Update errors.rst

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

* Update errors.rst


* Update errors.rst


* Update errors.rst

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

M Doc/tutorial/errors.rst

diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index efe44da3043c5..4a25861a050e6 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -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
     The above exception was the direct cause of the following exception:
@@ -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:

More information about the Python-checkins mailing list