FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-37651: Document CancelledError is now a subclass of BaseException… · python/cpython@7b69069 · GitHub

/ cpython Public

Commit 7b69069

Browse files
authored andcommitted
bpo-37651: Document CancelledError is now a subclass of BaseException (GH-15950)
https://bugs.python.org/issue37651 Automerge-Triggered-By: @1st1
1 parent 97b817e commit 7b69069

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

‎Doc/library/asyncio-exceptions.rst‎

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,9 @@ Exceptions
2525
when asyncio Tasks are cancelled. In almost all situations the
2626
exception must be re-raised.
2727

28-
.. important::
29-
30-
This exception is a subclass of :exc:`Exception`, so it can be
31-
accidentally suppressed by an overly broad ``try..except`` block::
32-
33-
try:
34-
await operation
35-
except Exception:
36-
# The cancellation is broken because the *except* block
37-
# suppresses the CancelledError exception.
38-
log.log('an error has occurred')
39-
40-
Instead, the following pattern should be used::
28+
.. versionchanged:: 3.8
4129

42-
try:
43-
await operation
44-
except asyncio.CancelledError:
45-
raise
46-
except Exception:
47-
log.log('an error has occurred')
30+
:exc:`CancelledError` is now a subclass of :class:`BaseException`.
4831

4932

5033
.. exception:: InvalidStateError

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL