mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	issue10883 - Silence some ftp related ResourceWarnings in test_urllib2net. Patch by Nadeem Vawda
This commit is contained in:
		
						commit
						e6ead3905d
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue