[Python-checkins] [3.6] bpo-31323: Fix reference leak in test_ssl (GH-3263) (#3538)
Victor Stinner
webhook-mailer at python.org
Wed Sep 13 06:27:37 EDT 2017
https://github.com/python/cpython/commit/1b00bddd5c4a5728b15eee5a27ed3f78a173ef64
commit: 1b00bddd5c4a5728b15eee5a27ed3f78a173ef64
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Victor Stinner <victor.stinner at gmail.com>
date: 2017-09-13T03:27:34-07:00
summary:
[3.6] bpo-31323: Fix reference leak in test_ssl (GH-3263) (#3538)
Store exceptions as string rather than object to prevent reference
cycles which cause leaking dangling threads.
(cherry picked from commit 868710158910fa38e285ce0e6d50026e1d0b2a8c)
files:
M Lib/test/test_ssl.py
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index e001badad17..54644e1596c 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -1867,7 +1867,11 @@ def wrap_conn(self):
# 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
@@ -3081,7 +3085,7 @@ def test_default_ciphers(self):
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):
"""
More information about the Python-checkins
mailing list