Commit 4223f89e authored by Tim Peters's avatar Tim Peters

Change ntpath.join() so that join("d:/", "/whatever") returns

d:/whatever instead of /whatever.  While I'm afraid changing isabs()
to be *consistent* with this would break lots of code, it makes
best sense for join() to do it this way.  Thanks to Alex Martelli for
pushing back on this one!
parent 76f373d0
...@@ -42,11 +42,12 @@ def join(a, *p): ...@@ -42,11 +42,12 @@ def join(a, *p):
"""Join two or more pathname components, inserting "\\" as needed""" """Join two or more pathname components, inserting "\\" as needed"""
path = a path = a
for b in p: for b in p:
# If path is a raw drive letter (e.g. "C:"), and b doesn't start # If path starts with a raw drive letter (e.g. "C:"), and b doesn't
# with a drive letter, path+b is correct, and regardless of whether # start with a drive letter, path+b is correct, and regardless of\
# b is absolute on its own. # whether b is absolute on its own.
if len(path) == 2 and path[-1] == ":" and splitdrive(b)[0] == "": if len(path) >= 2 and path[1] == ":" and splitdrive(b)[0] == "":
pass if path[-1] in "/\\" and b[:1] in "/\\":
b = b[1:]
# In any other case, if b is absolute it wipes out the path so far. # In any other case, if b is absolute it wipes out the path so far.
elif isabs(b) or path == "": elif isabs(b) or path == "":
......
...@@ -65,6 +65,7 @@ tester('ntpath.join("a", "b", "c")', 'a\\b\\c') ...@@ -65,6 +65,7 @@ tester('ntpath.join("a", "b", "c")', 'a\\b\\c')
tester('ntpath.join("a\\", "b", "c")', 'a\\b\\c') tester('ntpath.join("a\\", "b", "c")', 'a\\b\\c')
tester('ntpath.join("a", "b\\", "c")', 'a\\b\\c') tester('ntpath.join("a", "b\\", "c")', 'a\\b\\c')
tester('ntpath.join("a", "b", "\\c")', '\\c') tester('ntpath.join("a", "b", "\\c")', '\\c')
tester('ntpath.join("d:\\", "\\pleep")', 'd:\\pleep')
if errors: if errors:
raise TestFailed(str(errors) + " errors.") raise TestFailed(str(errors) + " errors.")
......
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