]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix description of behaviour of an exception class in 'from' clause (GH-24303) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 11 Apr 2021 08:53:16 +0000 (01:53 -0700)
committerGitHub <noreply@github.com>
Sun, 11 Apr 2021 08:53:16 +0000 (09:53 +0100)
(cherry picked from commit 79650d0118b0a8861428b9dd063089de405cf137)

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
Doc/reference/simple_stmts.rst

index f8ab2e918c6a10d19cb63f0d76ff2e9ad0338292..8691cbd0a47860d911e07f2b3927ce47933b7c73 100644 (file)
@@ -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)