This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author geertj
Recipients alex, christian.heimes, dstufft, geertj, giampaolo.rodola, janssen, pitrou
Date 2014-10-05.22:49:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1412549363.46.0.252406193768.issue22559@psf.upfronthosting.co.za>
In-reply-to
Content
> Right, socket._socketobject mearly nulls out the reference to _socket.socket, and lets reference counting take care of the rest.

Ugh this is bad... I thought close() was exactly there when you don't want to depend on refcounting for cleanup.

> * When do_handshake() raises an exception (say, a CertificateError), then a reference to a traceback is stored for sys.exc_info()
> * This traceback holds a reference to a frame where ssl.SSLObject is self
> * ssl.SSLObject holds a reference to _ssl._SSLSocket
> * Which holds a reference to _socket.socket

On Python 3.x the last one above is a weakref. 

> It seems like ``ssl.SSLSocket.close()`` should probably explicitly close the ``SSLObject`` somehow? I think this problem would appear on Python3 if you caught the exception manually and kept a reference to it?

On Python 3.x socket.close() does a real close() on the socket, it seems. (thought it appears to have an app-level refcount for makefile()). I agree this is the best way but it seems very scary to make that change for 2.7.

I think that closing the socket in SSLSocket.close(), as you suggest, would work (using socket._sock.close()), or or maybe you can make the "Socket" member in _SSLSocket a weakref?
History
Date User Action Args
2014-10-05 22:49:23geertjsetrecipients: + geertj, janssen, pitrou, giampaolo.rodola, christian.heimes, alex, dstufft
2014-10-05 22:49:23geertjsetmessageid: <1412549363.46.0.252406193768.issue22559@psf.upfronthosting.co.za>
2014-10-05 22:49:23geertjlinkissue22559 messages
2014-10-05 22:49:23geertjcreate