-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-42179: Doc/tutorial: Remove mention of __cause__ #23162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,10 +273,10 @@ Exception Chaining | |
================== | ||
|
||
The :keyword:`raise` statement allows an optional :keyword:`from` which enables | ||
chaining exceptions by setting the ``__cause__`` attribute of the raised | ||
exception. For example:: | ||
chaining exceptions. For example:: | ||
|
||
raise RuntimeError from OSError | ||
# exc must be ether exception instance or None. | ||
raise RuntimeError from exc | ||
|
||
This can be useful when you are transforming exceptions. For example:: | ||
|
||
|
@@ -299,10 +299,9 @@ This can be useful when you are transforming exceptions. For example:: | |
File "<stdin>", line 4, in <module> | ||
RuntimeError | ||
methane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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: | ||
Exception chaining happens automatically when an exception is raised inside an | ||
exception handler or :keyword:`finally` section. Exception chaining can be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of adding: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or possibly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used a parenthetical on purpose to signify that «exception handler» == «except block» (I wrote There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already use |
||
disabled by using ``from None`` idiom: | ||
|
||
>>> try: | ||
... open('database.sqlite') | ||
|
@@ -313,6 +312,8 @@ can be disabled by using ``from None`` idiom: | |
File "<stdin>", line 4, in <module> | ||
RuntimeError | ||
|
||
For more information about chaining mechanics, see :ref:`bltin-exceptions`. | ||
|
||
|
||
.. _tut-userexceptions: | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.