Skip to content

Commit

Permalink
exception variables assigned in except block are auto-deleted at the …
Browse files Browse the repository at this point in the history
…end of the block
  • Loading branch information
richardsheridan authored and belm0 committed Jan 31, 2021
1 parent 69f2de1 commit daf2b36
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit daf2b36

Please sign in to comment.