Skip to content
Browse files

bpo-37651: Document CancelledError is now a subclass of BaseException (

  • Loading branch information...
tirkarthi authored and miss-islington committed Sep 11, 2019
1 parent 97b817e commit 7b69069e9aa0047a0dbe8af1a67aa2b355dc68d8
Showing with 2 additions and 19 deletions.
  1. +2 −19 Doc/library/asyncio-exceptions.rst
@@ -25,26 +25,9 @@ Exceptions
when asyncio Tasks are cancelled. In almost all situations the
exception must be re-raised.

.. important::

This exception is a subclass of :exc:`Exception`, so it can be
accidentally suppressed by an overly broad ``try..except`` block::

await operation
except Exception:
# The cancellation is broken because the *except* block
# suppresses the CancelledError exception.
log.log('an error has occurred')

Instead, the following pattern should be used::
.. versionchanged:: 3.8

await operation
except asyncio.CancelledError:
except Exception:
log.log('an error has occurred')
:exc:`CancelledError` is now a subclass of :class:`BaseException`.

.. exception:: InvalidStateError

0 comments on commit 7b69069

Please sign in to comment.
You can’t perform that action at this time.