From daf2b36cb53fb7ae8a835da7937bb11a8809a9bb Mon Sep 17 00:00:00 2001 From: richardsheridan Date: Fri, 29 Jan 2021 11:02:06 -0500 Subject: [PATCH] exception variables assigned in except block are auto-deleted at the end of the block --- trio/_core/_run.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/trio/_core/_run.py b/trio/_core/_run.py index 234db2b803..14a61933db 100644 --- a/trio/_core/_run.py +++ b/trio/_core/_run.py @@ -2167,8 +2167,6 @@ def unrolled_run(runner, async_fn, args, host_uses_signal_set_wakeup_fd=False): msg = task.context.run(next_send_fn, next_send) except StopIteration as stop_iteration: final_outcome = Value(stop_iteration.value) - # prevent long-lived traceback reference - del stop_iteration except BaseException as task_exc: # Store for later, removing uninteresting top frames: 1 # frame we always remove, because it's this function @@ -2181,7 +2179,7 @@ def unrolled_run(runner, async_fn, args, host_uses_signal_set_wakeup_fd=False): # Remove local refs so that e.g. cancelled coroutine locals # are not kept alive by this frame until another exception # comes along. - del tb, task_exc + del tb if final_outcome is not None: # We can't call this directly inside the except: blocks