[issue22559] [backport] ssl.MemoryBIO

Alex Gaynor report at bugs.python.org
Mon Oct 6 00:25:10 CEST 2014


Alex Gaynor added the comment:

Right, socket._socketobject mearly nulls out the reference to _socket.socket, and lets reference counting take care of the rest.

I've more of less got this figured out:

* 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

This is avoided on Python3 because exceptions don't stick around, adding a ``sys.exc_clear()`` to that test causes it to not hang.

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?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22559>
_______________________________________


More information about the Python-bugs-list mailing list