mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -313,7 +313,7 @@ class TracebackFormatTests(unittest.TestCase):
|
|||
with captured_output("stderr") as stderr_f:
|
||||
try:
|
||||
f()
|
||||
except RecursionError as exc:
|
||||
except RecursionError:
|
||||
render_exc()
|
||||
else:
|
||||
self.fail("no recursion occurred")
|
||||
|
@ -360,7 +360,7 @@ class TracebackFormatTests(unittest.TestCase):
|
|||
with captured_output("stderr") as stderr_g:
|
||||
try:
|
||||
g()
|
||||
except ValueError as exc:
|
||||
except ValueError:
|
||||
render_exc()
|
||||
else:
|
||||
self.fail("no value error was raised")
|
||||
|
@ -396,7 +396,7 @@ class TracebackFormatTests(unittest.TestCase):
|
|||
with captured_output("stderr") as stderr_h:
|
||||
try:
|
||||
h()
|
||||
except ValueError as exc:
|
||||
except ValueError:
|
||||
render_exc()
|
||||
else:
|
||||
self.fail("no value error was raised")
|
||||
|
@ -424,7 +424,7 @@ class TracebackFormatTests(unittest.TestCase):
|
|||
with captured_output("stderr") as stderr_g:
|
||||
try:
|
||||
g(traceback._RECURSIVE_CUTOFF)
|
||||
except ValueError as exc:
|
||||
except ValueError:
|
||||
render_exc()
|
||||
else:
|
||||
self.fail("no error raised")
|
||||
|
@ -452,7 +452,7 @@ class TracebackFormatTests(unittest.TestCase):
|
|||
with captured_output("stderr") as stderr_g:
|
||||
try:
|
||||
g(traceback._RECURSIVE_CUTOFF + 1)
|
||||
except ValueError as exc:
|
||||
except ValueError:
|
||||
render_exc()
|
||||
else:
|
||||
self.fail("no error raised")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue