Merge: #10883: Fix socket leaks in urllib.request.

* ftpwrapper now uses reference counting to ensure that the underlying socket
  is closed when the ftpwrapper object is no longer in use
* ftplib.FTP.ntransfercmd() now closes the socket if an error occurs

Initial patch by Victor Stinner.
This commit is contained in:
Nadeem Vawda 2011-07-23 14:25:45 +02:00
commit 0200016132
4 changed files with 59 additions and 29 deletions

View file

@ -623,6 +623,7 @@ class HandlerTests(unittest.TestCase):
def retrfile(self, filename, filetype):
self.filename, self.filetype = filename, filetype
return io.StringIO(self.data), len(self.data)
def close(self): pass
class NullFTPHandler(urllib.request.FTPHandler):
def __init__(self, data): self.data = data