[Python-checkins] Fix description of behaviour of an exception class in 'from' clause (GH-24303) (GH-25342)

mdickinson webhook-mailer at python.org
Sun Apr 11 04:53:20 EDT 2021


https://github.com/python/cpython/commit/328d66c0715341f17343281c7b3d3032684e3c0a
commit: 328d66c0715341f17343281c7b3d3032684e3c0a
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: mdickinson <dickinsm at gmail.com>
date: 2021-04-11T09:53:16+01:00
summary:

Fix description of behaviour of an exception class in 'from' clause (GH-24303) (GH-25342)

(cherry picked from commit 79650d0118b0a8861428b9dd063089de405cf137)

Co-authored-by: Mark Dickinson <mdickinson at enthought.com>

Co-authored-by: Mark Dickinson <mdickinson at enthought.com>

files:
M Doc/reference/simple_stmts.rst

diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst
index f8ab2e918c6a1..8691cbd0a4786 100644
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -591,10 +591,13 @@ instance, with its traceback set to its argument), like so::
            __context__ (exception attribute)
 
 The ``from`` clause is used for exception chaining: if given, the second
-*expression* must be another exception class or instance, which will then be
-attached to the raised exception as the :attr:`__cause__` attribute (which is
-writable).  If the raised exception is not handled, both exceptions will be
-printed::
+*expression* must be another exception class or instance. If the second
+expression is an exception instance, it will be attached to the raised
+exception as the :attr:`__cause__` attribute (which is writable). If the
+expression is an exception class, the class will be instantiated and the
+resulting exception instance will be attached to the raised exception as the
+:attr:`__cause__` attribute. If the raised exception is not handled, both
+exceptions will be printed::
 
    >>> try:
    ...     print(1 / 0)



More information about the Python-checkins mailing list