Author dugan
Recipients dugan
Date 2009-02-13.00:34:36
SpamBayes Score 1.16597e-07
Marked as misclassified No
Message-id <>
The makefile function returns a socket._fileobject object with a
reference to itself, and also increments the makefile_refs variable.

However, the _fileobject is created with the parameter close=False,
which means that when you call _fileobject.close, it does not call close
on the ssl socket!  

>>> import socket, ssl
>>> s = socket.create_connection(('', 443))
>>> sslSocket = ssl.wrap_socket(s)
>>> f1 = sslSocket.makefile()
>>> f2 = sslSocket.makefile()
>>> f3 = sslSocket.makefile()
>>> sslSocket._makefile_refs
>>> sslSocket._sock
<socket object, fd=3, family=2, type=1, protocol=6>
>>> sslSocket.close()
>>> f1.close()
>>> f2.close()
>>> f3.close()
>>> sslSocket._makefile_refs

The quick fix is to add close=True on the _fileobject call in 
Note that this close=True is _not_ needed in the makefile call
as that makefile does not do reference counting.
Date User Action Args
2009-02-13 00:34:38dugansetrecipients: + dugan
2009-02-13 00:34:38dugansetmessageid: <>
2009-02-13 00:34:37duganlinkissue5238 messages
2009-02-13 00:34:36dugancreate