diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ntpath.py | 11 | ||||
-rw-r--r-- | Lib/test/test_ntpath.py | 1 |
2 files changed, 7 insertions, 5 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index d81e8fb..cf7c353 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -42,11 +42,12 @@ def join(a, *p): """Join two or more pathname components, inserting "\\" as needed""" path = a for b in p: - # If path is a raw drive letter (e.g. "C:"), and b doesn't start - # with a drive letter, path+b is correct, and regardless of whether - # b is absolute on its own. - if len(path) == 2 and path[-1] == ":" and splitdrive(b)[0] == "": - pass + # If path starts with a raw drive letter (e.g. "C:"), and b doesn't + # start with a drive letter, path+b is correct, and regardless of\ + # whether b is absolute on its own. + if len(path) >= 2 and path[1] == ":" and splitdrive(b)[0] == "": + 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. elif isabs(b) or path == "": diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index d1b7a00..7386900 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -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")', '\\c') +tester('ntpath.join("d:\\", "\\pleep")', 'd:\\pleep') if errors: raise TestFailed(str(errors) + " errors.") |