diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2011-03-24 03:47:29 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2011-03-24 03:47:29 (GMT) |
commit | e6ead3905d5ab9941a222f317b8282a326eb0d14 (patch) | |
tree | 33b8118696b3b33ca1ec4189e7f6521636e7ef3e /Lib/urllib | |
parent | f6d3e8eaef83c82416c2ca9d639ed59beba1f877 (diff) | |
parent | 2024acd36ffa0b39229425843bfae572b50ef6e3 (diff) | |
download | cpython-e6ead3905d5ab9941a222f317b8282a326eb0d14.zip cpython-e6ead3905d5ab9941a222f317b8282a326eb0d14.tar.gz cpython-e6ead3905d5ab9941a222f317b8282a326eb0d14.tar.bz2 |
issue10883 - Silence some ftp related ResourceWarnings in test_urllib2net. Patch by Nadeem Vawda
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index a501e37..0aa7a77 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2136,7 +2136,7 @@ class ftpwrapper: # Try to retrieve as a file try: cmd = 'RETR ' + file - conn = self.ftp.ntransfercmd(cmd) + conn, retrlen = self.ftp.ntransfercmd(cmd) except ftplib.error_perm as reason: if str(reason)[:3] != '550': raise URLError('ftp error', reason).with_traceback( @@ -2157,10 +2157,14 @@ class ftpwrapper: cmd = 'LIST ' + file else: cmd = 'LIST' - conn = self.ftp.ntransfercmd(cmd) + conn, retrlen = self.ftp.ntransfercmd(cmd) self.busy = 1 + + ftpobj = addclosehook(conn.makefile('rb'), self.endtransfer) + conn.close() # 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): if not self.busy: return |