summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-09-01 22:26:17 (GMT)
committerGitHub <noreply@github.com>2017-09-01 22:26:17 (GMT)
commit868710158910fa38e285ce0e6d50026e1d0b2a8c (patch)
tree333e880ed20124da9f876bb40f1738ad13240db9 /Lib/test/test_ssl.py
parente8a533fbc734af6eeb389202ba6c6e9c2548027f (diff)
downloadcpython-868710158910fa38e285ce0e6d50026e1d0b2a8c.zip
cpython-868710158910fa38e285ce0e6d50026e1d0b2a8c.tar.gz
cpython-868710158910fa38e285ce0e6d50026e1d0b2a8c.tar.bz2
bpo-31323: Fix reference leak in test_ssl (#3263)
Store exceptions as string rather than object to prevent reference cycles which cause leaking dangling threads.
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 104b7f3..5e143f9 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -1889,7 +1889,11 @@ if _have_threads:
# XXX Various errors can have happened here, for example
# a mismatching protocol version, an invalid certificate,
# or a low-level bug. This should be made more discriminating.
- self.server.conn_errors.append(e)
+ #
+ # bpo-31323: Store the exception as string to prevent
+ # a reference leak: server -> conn_errors -> exception
+ # -> traceback -> self (ConnectionHandler) -> server
+ self.server.conn_errors.append(str(e))
if self.server.chatty:
handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n")
self.running = False
@@ -3097,7 +3101,7 @@ if _have_threads:
with context.wrap_socket(socket.socket()) as s:
with self.assertRaises(OSError):
s.connect((HOST, server.port))
- self.assertIn("no shared cipher", str(server.conn_errors[0]))
+ self.assertIn("no shared cipher", server.conn_errors[0])
def test_version_basic(self):
"""