summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/ssl.py4
-rw-r--r--Lib/test/test_ssl.py8
-rw-r--r--Misc/NEWS2
3 files changed, 10 insertions, 4 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 889bea1..c8311bc 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -604,10 +604,6 @@ class SSLSocket(socket):
return None
return self._sslobj.tls_unique_cb()
- def __del__(self):
- # sys.stderr.write("__del__ on %s\n" % repr(self))
- self._real_close()
-
def wrap_socket(sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 2e559b1..7b72209 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -383,6 +383,14 @@ class BasicSocketTests(unittest.TestCase):
ss = ssl.wrap_socket(s, server_side=True, certfile=CERTFILE)
self.assertIsNone(ss.get_channel_binding("tls-unique"))
+ def test_dealloc_warn(self):
+ ss = ssl.wrap_socket(socket.socket(socket.AF_INET))
+ r = repr(ss)
+ with self.assertWarns(ResourceWarning) as cm:
+ ss = None
+ support.gc_collect()
+ self.assertIn(r, str(cm.warning.args[0]))
+
class ContextTests(unittest.TestCase):
@skip_if_broken_ubuntu_ssl
diff --git a/Misc/NEWS b/Misc/NEWS
index 7a2f8f2..5d49d0f 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -212,6 +212,8 @@ Core and Builtins
Library
-------
+- Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed.
+
- Issue #15545: Fix regression in sqlite3's iterdump method where it was
failing if the connection used a row factory (such as sqlite3.Row) that
produced unsortable objects. (Regression was introduced by fix for 9750).