summaryrefslogtreecommitdiffstats
path: root/Lib/posixpath.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-01-12 03:32:05 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-01-12 03:32:05 (GMT)
commitb5689de04425775932331b153feee7d9598755ad (patch)
tree15cbe6eeb2e7cbe83379c586ccf696583d617107 /Lib/posixpath.py
parent58a96efde53a52d501cdf6db810fedb1d86ecdb9 (diff)
downloadcpython-b5689de04425775932331b153feee7d9598755ad.zip
cpython-b5689de04425775932331b153feee7d9598755ad.tar.gz
cpython-b5689de04425775932331b153feee7d9598755ad.tar.bz2
#5827: make sure that normpath preserves unicode
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r--Lib/posixpath.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 15be83c..297b68e 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):