Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df56386

Browse files
committed
* posixpath.py: Fix border cases in normpath ('/foo/..' should return '/')
* ftplib.py: made cwd() use 'CDUP' when dirname is '..' * FL.py: added new constant FL_PLACE_FULLSCREEN
1 parent f1dc566 commit df56386

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

Lib/ftplib.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,11 @@ def rename(self, fromname, toname):
336336

337337
# Change to a directory
338338
def cwd(self, dirname):
339-
self.voidcmd('CWD ' + dirname)
339+
if dirname == '..':
340+
cmd = 'CDUP'
341+
else:
342+
cmd = 'CWD ' + dirname
343+
self.voidcmd(cmd)
340344

341345
# Retrieve the size of a file
342346
def size(self, filename):

Lib/irix5/FL.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
PLACE_MOUSE = 3
2828
PLACE_CENTER = 4
2929
PLACE_POSITION = 5
30+
FL_PLACE_FULLSCREEN = 6
3031
FIND_INPUT = 0
3132
FIND_AUTOMATIC = 1
3233
FIND_MOUSE = 2

Lib/plat-irix5/FL.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
PLACE_MOUSE = 3
2828
PLACE_CENTER = 4
2929
PLACE_POSITION = 5
30+
FL_PLACE_FULLSCREEN = 6
3031
FIND_INPUT = 0
3132
FIND_AUTOMATIC = 1
3233
FIND_MOUSE = 2

Lib/posixpath.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,12 @@ def expandvars(path):
270270

271271
def normpath(path):
272272
import string
273+
# Treat initial slashes specially
274+
slashes = ''
275+
while path[:1] == '/':
276+
slashes = slashes + '/'
277+
path = path[1:]
273278
comps = string.splitfields(path, '/')
274-
# If the path begins with '/', comps[0] is '', which we leave alone;
275-
# we also leave leading multiple slashes alone for compatibility
276-
# with certain networking naming schemes using //host/path
277279
i = 0
278280
while i < len(comps):
279281
if comps[i] == '.':
@@ -287,6 +289,6 @@ def normpath(path):
287289
else:
288290
i = i+1
289291
# If the path is now empty, substitute '.'
290-
if not comps:
292+
if not comps and not slashes:
291293
comps.append('.')
292-
return string.joinfields(comps, '/')
294+
return slashes + string.joinfields(comps, '/')

0 commit comments

Comments
 (0)