Fix the leaks in test_ssl. Issue 1469. Patch by Christian Heimes:
(a) added GC support to the PySSL object
(b) move the call to _real_close() from __del__ methods in Python to
PySSL_dealloc().
(c) remove those __del__ methods -- this makes SSL and socket objects GC'able.
diff --git a/Lib/ssl.py b/Lib/ssl.py
index be13866..a6619d6 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -148,6 +148,10 @@
self.do_handshake_on_connect = do_handshake_on_connect
self.suppress_ragged_eofs = suppress_ragged_eofs
+ # See Modules/_ssl.c:PySSL_dealloc()
+ # def __del__(self):
+ # self._real_close()
+
def dup(self):
raise NotImplemented("Can't dup() %s instances" %
self.__class__.__name__)
@@ -300,6 +304,7 @@
socket.shutdown(self, how)
def _real_close(self):
+ # real close is called by Modules/_ssl.c:PySSL_dealloc()
self._sslobj = None
# self._closed = True
if self._base:
@@ -348,10 +353,6 @@
self.do_handshake_on_connect),
addr)
-
- def __del__(self):
- self._real_close()
-
def wrap_socket(sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
ssl_version=PROTOCOL_SSLv23, ca_certs=None,