mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
4b28041530
commit
03b5c9ae75
2 changed files with 64 additions and 16 deletions
|
@ -148,6 +148,10 @@ class SSLSocket(socket):
|
|||
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 @@ class SSLSocket(socket):
|
|||
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 @@ class SSLSocket(socket):
|
|||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue