[Python-checkins] bpo-37651: Document CancelledError is now a subclass of BaseException (GH-15950)

Miss Islington (bot) webhook-mailer at python.org
Wed Sep 11 11:08:51 EDT 2019


https://github.com/python/cpython/commit/e784bb7c6b2a52e80d7c03cb85e5faab11a1ccbd
commit: e784bb7c6b2a52e80d7c03cb85e5faab11a1ccbd
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-09-11T08:08:47-07:00
summary:

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


https://bugs.python.org/issue37651

Automerge-Triggered-By: @1st1
(cherry picked from commit 7b69069e9aa0047a0dbe8af1a67aa2b355dc68d8)

Co-authored-by: Xtreak <tir.karthi at gmail.com>

files:
M Doc/library/asyncio-exceptions.rst

diff --git a/Doc/library/asyncio-exceptions.rst b/Doc/library/asyncio-exceptions.rst
index e49577a203e8..b1e6ecfda15e 100644
--- a/Doc/library/asyncio-exceptions.rst
+++ b/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::
-
-        try:
-            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
 
-        try:
-            await operation
-        except asyncio.CancelledError:
-            raise
-        except Exception:
-            log.log('an error has occurred')
+      :exc:`CancelledError` is now a subclass of :class:`BaseException`.
 
 
 .. exception:: InvalidStateError



More information about the Python-checkins mailing list