diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2010-01-12 03:38:53 +0000 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2010-01-12 03:38:53 +0000 |
commit | 698037a232543437a6ac0ef3ab5067da2930dda0 (patch) | |
tree | 2db2a3ee945f9668e0d092374358109782e5ba25 /Lib/posixpath.py | |
parent | 0d54bd5122b9787ff5bbbf06003df40c9e7809a6 (diff) | |
download | cpython-git-698037a232543437a6ac0ef3ab5067da2930dda0.tar.gz |
Merged revisions 77442 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77442 | ezio.melotti | 2010-01-12 05:32:05 +0200 (Tue, 12 Jan 2010) | 1 line
#5827: make sure that normpath preserves unicode
........
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r-- | Lib/posixpath.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py index cdce5afede..35dcffbe88 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -307,8 +307,10 @@ def expandvars(path): def normpath(path): """Normalize path, eliminating double slashes, etc.""" + # Preserve unicode (if path is unicode) + slash, dot = (u'/', u'.') if isinstance(path, unicode) else ('/', '.') if path == '': - return '.' + return dot initial_slashes = path.startswith('/') # POSIX allows one or two initial slashes, but treats three or more # as single slash. @@ -326,10 +328,10 @@ def normpath(path): elif new_comps: new_comps.pop() comps = new_comps - path = '/'.join(comps) + path = slash.join(comps) if initial_slashes: - path = '/'*initial_slashes + path - return path or '.' + path = slash*initial_slashes + path + return path or dot def abspath(path): |