summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-10-22 16:05:11 (GMT)
committerGitHub <noreply@github.com>2022-10-22 16:05:11 (GMT)
commitf4a14941e6e54b15012fca067f6a9b2ff29f201a (patch)
treec7f459b8a71250669a026caf8f4c7e180fb708fc /Lib/asyncio
parent5871e19942fdcf83653924ae9a849941669c1143 (diff)
downloadcpython-f4a14941e6e54b15012fca067f6a9b2ff29f201a.zip
cpython-f4a14941e6e54b15012fca067f6a9b2ff29f201a.tar.gz
cpython-f4a14941e6e54b15012fca067f6a9b2ff29f201a.tar.bz2
GH-98543: Fix `asyncio.TaskGroup` to not keep reference to errors after raising ExceptionGroup (#98544)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/taskgroups.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py
index 5d5e2a8..911419e 100644
--- a/Lib/asyncio/taskgroups.py
+++ b/Lib/asyncio/taskgroups.py
@@ -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: