mirror of
https://github.com/python/cpython.git
synced 2025-08-26 03:34:43 +00:00
SF bug 478425: Change in os.path.join (ntpath.py)
ntpath.join('a', '') was producing 'a' instead of 'a\\' as in 2.1. Impossible to guess what was ever *intended*, but since split('a\\') produces ('a', ''), I think it's best if join('a', '') gives 'a\\' back.
This commit is contained in:
parent
2a9e3852ee
commit
6a3e5f14a6
2 changed files with 14 additions and 0 deletions
|
@ -82,6 +82,12 @@ def join(a, *p):
|
||||||
path += b
|
path += b
|
||||||
else:
|
else:
|
||||||
path += "\\" + b
|
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
|
return path
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,14 @@ tester("ntpath.join('c:', 'd:/')", 'd:/')
|
||||||
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('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/./B')", r'A\B')
|
tester("ntpath.normpath('A/./B')", r'A\B')
|
||||||
tester("ntpath.normpath('A/foo/../B')", r'A\B')
|
tester("ntpath.normpath('A/foo/../B')", r'A\B')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue