mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Remove binding of captured exceptions when not used to reduce the chances of creating cycles (GH-17246)
Capturing exceptions into names can lead to reference cycles though the __traceback__ attribute of the exceptions in some obscure cases that have been reported previously and fixed individually. As these variables are not used anyway, we can remove the binding to reduce the chances of creating reference cycles. See for example GH-13135
This commit is contained in:
parent
c6b20be85c
commit
293dd23477
28 changed files with 39 additions and 39 deletions
|
@ -161,8 +161,8 @@ def raises():
|
|||
def test_raise():
|
||||
try:
|
||||
raises()
|
||||
except Exception as exc:
|
||||
x = 1
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
test_raise.events = [(0, 'call'),
|
||||
(1, 'line'),
|
||||
|
@ -191,7 +191,7 @@ def _settrace_and_raise(tracefunc):
|
|||
def settrace_and_raise(tracefunc):
|
||||
try:
|
||||
_settrace_and_raise(tracefunc)
|
||||
except RuntimeError as exc:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
settrace_and_raise.events = [(2, 'exception'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue