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:
Pablo Galindo 2019-11-19 21:34:03 +00:00 committed by GitHub
parent c6b20be85c
commit 293dd23477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 39 additions and 39 deletions

View file

@ -31,7 +31,7 @@ class TestCgitb(unittest.TestCase):
def test_text(self):
try:
raise ValueError("Hello World")
except ValueError as err:
except ValueError:
text = cgitb.text(sys.exc_info())
self.assertIn("ValueError", text)
self.assertIn("Hello World", text)