]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix bad new bug in ftp code -- the test for existing file using NLST
authorGuido van Rossum <guido@python.org>
Mon, 19 Jan 1998 22:26:54 +0000 (22:26 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 19 Jan 1998 22:26:54 +0000 (22:26 +0000)
would set the transfer to text mode instead of the specified mode.

Lib/urllib.py

index b9a82d169211213f9fd153c3bcb59ba7815f099c..8ecef031cf0ff2c14ac4be8d25c4304a06f92fbe 100644 (file)
@@ -521,6 +521,8 @@ class ftpwrapper:
                        except ftplib.error_perm, reason:
                                raise IOError, ('ftp error', reason), \
                                      sys.exc_info()[2]
+                       # Restore the transfer mode!
+                       self.ftp.voidcmd(cmd)
                        # Try to retrieve as a file
                        try:
                                cmd = 'RETR ' + file
@@ -530,6 +532,8 @@ class ftpwrapper:
                                        raise IOError, ('ftp error', reason), \
                                              sys.exc_info()[2]
                if not conn:
+                       # Set transfer mode to ASCII!
+                       self.ftp.voidcmd('TYPE A')
                        # Try a directory listing
                        if file: cmd = 'LIST ' + file
                        else: cmd = 'LIST'