Commit 459bae89 authored by Senthil Kumaran's avatar Senthil Kumaran

issue10883 - Silence some ftp related ResourceWarnings in test_urllib2net. Patch by Nadeem Vawda.

parent 945f8ef9
...@@ -2136,7 +2136,7 @@ class ftpwrapper: ...@@ -2136,7 +2136,7 @@ class ftpwrapper:
# Try to retrieve as a file # Try to retrieve as a file
try: try:
cmd = 'RETR ' + file cmd = 'RETR ' + file
conn = self.ftp.ntransfercmd(cmd) conn, retrlen = self.ftp.ntransfercmd(cmd)
except ftplib.error_perm as reason: except ftplib.error_perm as reason:
if str(reason)[:3] != '550': if str(reason)[:3] != '550':
raise URLError('ftp error', reason).with_traceback( raise URLError('ftp error', reason).with_traceback(
...@@ -2157,10 +2157,14 @@ class ftpwrapper: ...@@ -2157,10 +2157,14 @@ class ftpwrapper:
cmd = 'LIST ' + file cmd = 'LIST ' + file
else: else:
cmd = 'LIST' cmd = 'LIST'
conn = self.ftp.ntransfercmd(cmd) conn, retrlen = self.ftp.ntransfercmd(cmd)
self.busy = 1 self.busy = 1
ftpobj = addclosehook(conn.makefile('rb'), self.endtransfer)
conn.close()
# Pass back both a suitably decorated object and a retrieval length # Pass back both a suitably decorated object and a retrieval length
return (addclosehook(conn[0].makefile('rb'), self.endtransfer), conn[1]) return (ftpobj, retrlen)
def endtransfer(self): def endtransfer(self):
if not self.busy: if not self.busy:
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment