Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch asyncio.CancelledError in 3.8 when calling fut.exception() on a Task object #2218

Closed
wants to merge 1 commit into from

Conversation

@bmintz
Copy link
Contributor

commented Jun 13, 2019

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

Summary

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@bmintz bmintz changed the title catch all exceptions when calling fut.exception() on a Task object catch asyncio.CancelledError in 3.8 when calling fut.exception() on a Task object Jun 13, 2019

catch asyncio.CancelledError in 3.8 when calling fut.exception() on a…
… Task object

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
```
@xoxfaby

This comment has been minimized.

Copy link

commented Jun 19, 2019

https://bugs.python.org/issue32528
python/cpython@431b540

Makes sense to me, this change is definitely needed for 3.8 compatibility.

@Rapptz Rapptz added the rebased label Jun 21, 2019

@Rapptz Rapptz closed this Jun 21, 2019

@bmintz bmintz deleted the bmintz:3.8-CancelledError-inherits-BaseException branch Jun 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.