GH-95704: Don't suppress errors from tasks when TG is cancelled (#95761)

When a task catches CancelledError and raises some other error,
the other error should not silently be suppressed.

Any scenario where a task crashes in cleanup upon cancellation
will now result in an ExceptionGroup wrapping the crash(es)
instead of propagating CancelledError and ignoring the side errors.

NOTE: This represents a change in behavior (hence the need to
change several tests).  But it is only an edge case.

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
This commit is contained in:
Guido van Rossum 2022-08-16 18:23:06 -07:00 committed by GitHub
parent 9b30b965f0
commit f51f54f39d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 28 deletions

View file

@ -0,0 +1,2 @@
When a task catches :exc:`asyncio.CancelledError` and raises some other error,
the other error should generally not silently be suppressed.