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
```
This commit is contained in:
Benjamin Mintz 2019-06-13 19:38:07 +00:00 committed by Rapptz
parent 671a19a24a
commit 850a0431bf

View File

@ -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: