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 dugan
Recipients dugan
Date 2009-02-13.00:34:36
SpamBayes Score 1.1659698e-07
Marked as misclassified No
Message-id <1234485278.29.0.554185864263.issue5238@psf.upfronthosting.co.za>
In-reply-to
Content
The ssl.py 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(('www.rpath.com', 443))
>>> sslSocket = ssl.wrap_socket(s)
>>> f1 = sslSocket.makefile()
>>> f2 = sslSocket.makefile()
>>> f3 = sslSocket.makefile()
>>> sslSocket._makefile_refs
3
>>> sslSocket._sock
<socket object, fd=3, family=2, type=1, protocol=6>
>>> sslSocket.close()
>>> f1.close()
>>> f2.close()
>>> f3.close()
>>> sslSocket._makefile_refs
2

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