From 850a0431bfe869ca03ee22d7be5c4c7692166eab Mon Sep 17 00:00:00 2001 From: Benjamin Mintz Date: Thu, 13 Jun 2019 19:38:07 +0000 Subject: [PATCH] Catch asyncio.CancelledError in 3.8 in typing context manager In python 3.8, asyncio.CancelledError is a subclass of BaseException rather than Exception, so `except Exception:` will not swallow CancelledError. This change prevents an error in 3.8 from being printed to the console when the following is run: ``` async with ctx.typing(): pass ``` --- discord/context_managers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/context_managers.py b/discord/context_managers.py index 387518312..e7ac501c6 100644 --- a/discord/context_managers.py +++ b/discord/context_managers.py @@ -30,7 +30,7 @@ def _typing_done_callback(fut): # just retrieve any exception and call it a day try: fut.exception() - except Exception: + except (asyncio.CancelledError, Exception): pass class Typing: