Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Doc/tutorial/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ This can be useful when you are transforming exceptions. For example::

The expression following the :keyword:`from` must be either an exception or
``None``. Exception chaining happens automatically when an exception is raised
inside an exception handler or :keyword:`finally` section. Exception chaining
can be disabled by using ``from None`` idiom:
inside an exception handler or :keyword:`finally` section, however in this case
``__context__`` attribute of the exception is used. Chaining with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend submitting this sentence right before the builtin exceptions sentence after #23162 lands. Then add "Chaining with ... takes priority."

``__context__`` works similarly to chaining with ``__cause__``,
but when formatting exception traceback ``__cause__`` takes priority.
For more information about chaining mechanics see :ref:`bltin-exceptions`.

Exception chaining can be disabled by using ``from None`` idiom:

>>> try:
... open('database.sqlite')
Expand Down