New submission from David Christian <d...@rpath.com>:

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.

----------
messages: 81842
nosy: dugan
severity: normal
status: open
title: ssl makefile never closes socket
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5238>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to