Skip to content

Commit 328d66c

Browse files
Fix description of behaviour of an exception class in 'from' clause (GH-24303) (GH-25342)
(cherry picked from commit 79650d0) Co-authored-by: Mark Dickinson <[email protected]> Co-authored-by: Mark Dickinson <[email protected]>
1 parent 3a3c046 commit 328d66c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Doc/reference/simple_stmts.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,13 @@ instance, with its traceback set to its argument), like so::
591591
__context__ (exception attribute)
592592

593593
The ``from`` clause is used for exception chaining: if given, the second
594-
*expression* must be another exception class or instance, which will then be
595-
attached to the raised exception as the :attr:`__cause__` attribute (which is
596-
writable). If the raised exception is not handled, both exceptions will be
597-
printed::
594+
*expression* must be another exception class or instance. If the second
595+
expression is an exception instance, it will be attached to the raised
596+
exception as the :attr:`__cause__` attribute (which is writable). If the
597+
expression is an exception class, the class will be instantiated and the
598+
resulting exception instance will be attached to the raised exception as the
599+
:attr:`__cause__` attribute. If the raised exception is not handled, both
600+
exceptions will be printed::
598601

599602
>>> try:
600603
... print(1 / 0)

0 commit comments

Comments
 (0)