Skip to content
Snippets Groups Projects
Commit e09c6f54cb9f authored by Mark Dickinson's avatar Mark Dickinson
Browse files

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

parent 1ff5d074318e
No related branches found
No related tags found
No related merge requests found
......@@ -591,10 +591,13 @@
__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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment