diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index fb9c9a2ff5f..eab15ab61a6 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -14,6 +14,7 @@ import urllib.parse, urllib.request import shutil import traceback import asyncore +import weakref from http.server import HTTPServer, SimpleHTTPRequestHandler @@ -97,6 +98,16 @@ class BasicTests(unittest.TestCase): if (d1 != d2): raise support.TestFailed("PEM-to-DER or DER-to-PEM translation failed") + @support.cpython_only + def test_refcycle(self): + # Issue #7943: an SSL object doesn't create reference cycles with + # itself. + s = socket.socket(socket.AF_INET) + ss = ssl.wrap_socket(s) + wr = weakref.ref(ss) + del ss + self.assertEqual(wr(), None) + class NetworkedTests(unittest.TestCase): def testConnect(self):