[3.11] GH-98543: Fix asyncio.TaskGroup to not keep reference to errors after raising ExceptionGroup (GH-98544) (#98550)

GH-98543: Fix `asyncio.TaskGroup`  to not keep reference to errors after raising ExceptionGroup  (GH-98544)
(cherry picked from commit f4a14941e6)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-10-24 11:08:22 -07:00 committed by GitHub
parent 032d1276ed
commit 36d25a4f7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -128,11 +128,11 @@ class TaskGroup:
# Exceptions are heavy objects that can have object
# cycles (bad for GC); let's not keep a reference to
# a bunch of them.
errors = self._errors
self._errors = None
me = BaseExceptionGroup('unhandled errors in a TaskGroup', errors)
raise me from None
try:
me = BaseExceptionGroup('unhandled errors in a TaskGroup', self._errors)
raise me from None
finally:
self._errors = None
def create_task(self, coro, *, name=None, context=None):
if not self._entered: