Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Update errors.rst
Clarify exception chaining behaviour and give a reference to the library documentation.
  • Loading branch information
greatvovan authored Nov 5, 2020
commit 86fe587f02a2bd317c9c92b567649b192bca91b1
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
Copy Markdown
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, 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