]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* posixpath.py: Fix border cases in normpath ('/foo/..' should return '/')
authorGuido van Rossum <guido@python.org>
Tue, 6 Jul 1993 15:19:36 +0000 (15:19 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 6 Jul 1993 15:19:36 +0000 (15:19 +0000)
* ftplib.py: made cwd() use 'CDUP' when dirname is '..'
* FL.py: added new constant FL_PLACE_FULLSCREEN

Lib/ftplib.py
Lib/irix5/FL.py
Lib/plat-irix5/FL.py
Lib/posixpath.py

index e846ffe30b207125363cdcd51a9820ac24266969..8342b0977b1a3f64422615a95f470217666fb4b4 100644 (file)
@@ -336,7 +336,11 @@ class FTP:
 
        # Change to a directory
        def cwd(self, dirname):
-               self.voidcmd('CWD ' + dirname)
+               if dirname == '..':
+                       cmd = 'CDUP'
+               else:
+                       cmd = 'CWD ' + dirname
+               self.voidcmd(cmd)
 
        # Retrieve the size of a file
        def size(self, filename):
index 65184dfe1f965d31db55882a34a1db47bc085539..f85237b85f9b88cd5619c18f4a5fe4444c7fb579 100755 (executable)
@@ -27,6 +27,7 @@ PLACE_ASPECT = 2
 PLACE_MOUSE = 3
 PLACE_CENTER = 4
 PLACE_POSITION = 5
+FL_PLACE_FULLSCREEN = 6
 FIND_INPUT = 0
 FIND_AUTOMATIC = 1
 FIND_MOUSE = 2
index 65184dfe1f965d31db55882a34a1db47bc085539..f85237b85f9b88cd5619c18f4a5fe4444c7fb579 100755 (executable)
@@ -27,6 +27,7 @@ PLACE_ASPECT = 2
 PLACE_MOUSE = 3
 PLACE_CENTER = 4
 PLACE_POSITION = 5
+FL_PLACE_FULLSCREEN = 6
 FIND_INPUT = 0
 FIND_AUTOMATIC = 1
 FIND_MOUSE = 2
index 57b0af68c6f121951656f9d3c37e775cfb954a9d..96116d10679c6971b4e8b0cfa45cfd7481df4ddd 100644 (file)
@@ -270,10 +270,12 @@ def expandvars(path):
 
 def normpath(path):
        import string
+       # Treat initial slashes specially
+       slashes = ''
+       while path[:1] == '/':
+               slashes = slashes + '/'
+               path = path[1:]
        comps = string.splitfields(path, '/')
-       # If the path begins with '/', comps[0] is '', which we leave alone;
-       # we also leave leading multiple slashes alone for compatibility
-       # with certain networking naming schemes using //host/path
        i = 0
        while i < len(comps):
                if comps[i] == '.':
@@ -287,6 +289,6 @@ def normpath(path):
                else:
                        i = i+1
        # If the path is now empty, substitute '.'
-       if not comps:
+       if not comps and not slashes:
                comps.append('.')
-       return string.joinfields(comps, '/')
+       return slashes + string.joinfields(comps, '/')