From 293dd23477eef6e7c1b1e26b5bb2c1e0d79ac3c2 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Tue, 19 Nov 2019 21:34:03 +0000 Subject: 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 --- Lib/test/test_traceback.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Lib/test/test_traceback.py') diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 72dc7afb8c..7135d997d5 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -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") -- cgit v1.2.1