Commit 7f7aadbb authored by Guido van Rossum's avatar Guido van Rossum

(1) Change normpath() to *not* also call normcase().

(2) Fix normcase() to use string.lower() and string.replace() -- it
turns out that the table constructed for translate() didn't work in
locales that have a different number of lowercase and uppercase
letters.
parent 167f432d
...@@ -13,13 +13,13 @@ import string ...@@ -13,13 +13,13 @@ import string
# Other normalizations (such as optimizing '../' away) are not done # Other normalizations (such as optimizing '../' away) are not done
# (this is done by normpath). # (this is done by normpath).
_normtable = string.maketrans(string.uppercase + "\\/",
string.lowercase + os.sep * 2)
def normcase(s): def normcase(s):
"""Normalize case of pathname. Makes all characters lowercase and all """Normalize case of pathname.
slashes into backslashes"""
return string.translate(s, _normtable) Makes all characters lowercase and all slashes into backslashes.
"""
return string.lower(string.replace(s, "/", "\\"))
# Return wheter a path is absolute. # Return wheter a path is absolute.
...@@ -356,7 +356,7 @@ are left unchanged""" ...@@ -356,7 +356,7 @@ are left unchanged"""
def normpath(path): def normpath(path):
"""Normalize path, eliminating double slashes, etc.""" """Normalize path, eliminating double slashes, etc."""
path = normcase(path) path = string.replace(path, "/", "\\")
prefix, path = splitdrive(path) prefix, path = splitdrive(path)
while path[:1] == os.sep: while path[:1] == os.sep:
prefix = prefix + os.sep prefix = prefix + os.sep
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment