summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/ntpath.py6
-rw-r--r--Lib/test/test_ntpath.py8
2 files changed, 14 insertions, 0 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index ed8a2dd..21fadd0 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -82,6 +82,12 @@ def join(a, *p):
path += b
else:
path += "\\" + b
+ else:
+ # path is not empty and does not end with a backslash,
+ # but b is empty; since, e.g., split('a/') produces
+ # ('a', ''), it's best if join() adds a backslash in
+ # this case.
+ path += '\\'
return path
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 049bbc1..98569f9 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -74,6 +74,14 @@ tester("ntpath.join('c:', 'd:/')", 'd:/')
tester("ntpath.join('c:/', 'd:/')", 'd:/')
tester("ntpath.join('c:/', 'd:/a/b')", 'd:/a/b')
+tester("ntpath.join('')", '')
+tester("ntpath.join('', '', '', '', '')", '')
+tester("ntpath.join('a')", 'a')
+tester("ntpath.join('', 'a')", 'a')
+tester("ntpath.join('', '', '', '', 'a')", 'a')
+tester("ntpath.join('a', '')", 'a\\')
+tester("ntpath.join('a', '', '', '', '')", 'a\\')
+
tester("ntpath.normpath('A//////././//.//B')", r'A\B')
tester("ntpath.normpath('A/./B')", r'A\B')
tester("ntpath.normpath('A/foo/../B')", r'A\B')