summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-11-19 21:34:03 (GMT)
committerGitHub <noreply@github.com>2019-11-19 21:34:03 (GMT)
commit293dd23477eef6e7c1b1e26b5bb2c1e0d79ac3c2 (patch)
tree295b4eee204f0d1e4723e62825a86310ddc27578 /Lib/test
parentc6b20be85c0de6f2355c67ae6e7e578941275cc0 (diff)
downloadcpython-293dd23477eef6e7c1b1e26b5bb2c1e0d79ac3c2.zip
cpython-293dd23477eef6e7c1b1e26b5bb2c1e0d79ac3c2.tar.gz
cpython-293dd23477eef6e7c1b1e26b5bb2c1e0d79ac3c2.tar.bz2
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
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/pythoninfo.py2
-rw-r--r--Lib/test/test_cgitb.py2
-rw-r--r--Lib/test/test_class.py2
-rw-r--r--Lib/test/test_codecs.py2
-rw-r--r--Lib/test/test_decimal.py4
-rw-r--r--Lib/test/test_ftplib.py2
-rw-r--r--Lib/test/test_sys_settrace.py6
-rw-r--r--Lib/test/test_time.py2
-rw-r--r--Lib/test/test_traceback.py10
-rw-r--r--Lib/test/test_urllib2net.py2
-rw-r--r--Lib/test/test_uuid.py2
11 files changed, 18 insertions, 18 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 797b3af..eab82c3 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -754,7 +754,7 @@ def collect_info(info):
):
try:
collect_func(info_add)
- except Exception as exc:
+ except Exception:
error = True
print("ERROR: %s() failed" % (collect_func.__name__),
file=sys.stderr)
diff --git a/Lib/test/test_cgitb.py b/Lib/test/test_cgitb.py
index e299ec3..8991bc1 100644
--- a/Lib/test/test_cgitb.py
+++ b/Lib/test/test_cgitb.py
@@ -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)
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index 456f1be..7524f58 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -529,7 +529,7 @@ class ClassTests(unittest.TestCase):
# In debug mode, printed XXX undetected error and
# raises AttributeError
I()
- except AttributeError as x:
+ except AttributeError:
pass
else:
self.fail("attribute error for I.__init__ got masked")
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index e1638c1..3aec34c 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -11,7 +11,7 @@ from test import support
try:
import _testcapi
-except ImportError as exc:
+except ImportError:
_testcapi = None
try:
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 1f37b53..fe0cfc7 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -5600,13 +5600,13 @@ class SignatureTest(unittest.TestCase):
args, kwds = mkargs(C, c_sig)
try:
getattr(c_type(9), attr)(*args, **kwds)
- except Exception as err:
+ except Exception:
raise TestFailed("invalid signature for %s: %s %s" % (c_func, args, kwds))
args, kwds = mkargs(P, p_sig)
try:
getattr(p_type(9), attr)(*args, **kwds)
- except Exception as err:
+ except Exception:
raise TestFailed("invalid signature for %s: %s %s" % (p_func, args, kwds))
doit('Decimal')
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index b0e4641..b8eef82 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -346,7 +346,7 @@ if ssl is not None:
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
ssl.SSL_ERROR_WANT_WRITE):
return
- except OSError as err:
+ except OSError:
# Any "socket error" corresponds to a SSL_ERROR_SYSCALL return
# from OpenSSL's SSL_shutdown(), corresponding to a
# closed socket condition. See also:
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index fdd7894..d4e1ac2 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -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'),
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 8d8d31e..80e43fa 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -825,7 +825,7 @@ class CPyTimeTestCase:
try:
result = pytime_converter(value, time_rnd)
expected = expected_func(value)
- except Exception as exc:
+ except Exception:
self.fail("Error on timestamp conversion: %s" % debug_info)
self.assertEqual(result,
expected,
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 72dc7af..7135d99 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")
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index 040a2ce..bb0500e 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -199,7 +199,7 @@ class OtherNetworkTests(unittest.TestCase):
try:
with urllib.request.urlopen(URL) as res:
pass
- except ValueError as e:
+ except ValueError:
self.fail("urlopen failed for site not sending \
Connection:close")
else:
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index ddf7e6d..b76c60e 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -471,7 +471,7 @@ class BaseTestUUID:
# the value from too_large_getter above.
try:
self.uuid.uuid1(node=node)
- except ValueError as e:
+ except ValueError:
self.fail('uuid1 was given an invalid node ID')
def test_uuid1(self):