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

This commit is contained in:
Kumar Aditya 2022-10-22 21:35:11 +05:30 committed by GitHub
parent 5871e19942
commit f4a14941e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

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: