mirror of https://github.com/python/cpython
GH-103220: Fix `ntpath.join()` of partial UNC drive with trailing slash (GH-103221)
This commit is contained in:
parent
50b4b15984
commit
b57105ae33
|
@ -142,7 +142,7 @@ def join(path, *paths):
|
||||||
result_path = result_path + p_path
|
result_path = result_path + p_path
|
||||||
## add separator between UNC and non-absolute path
|
## add separator between UNC and non-absolute path
|
||||||
if (result_path and not result_root and
|
if (result_path and not result_root and
|
||||||
result_drive and result_drive[-1:] != colon):
|
result_drive and result_drive[-1:] not in colon + seps):
|
||||||
return result_drive + sep + result_path
|
return result_drive + sep + result_path
|
||||||
return result_drive + result_root + result_path
|
return result_drive + result_root + result_path
|
||||||
except (TypeError, AttributeError, BytesWarning):
|
except (TypeError, AttributeError, BytesWarning):
|
||||||
|
|
|
@ -300,6 +300,11 @@ class TestNtpath(NtpathTestCase):
|
||||||
tester("ntpath.join('//computer/share', 'a', 'b')", '//computer/share\\a\\b')
|
tester("ntpath.join('//computer/share', 'a', 'b')", '//computer/share\\a\\b')
|
||||||
tester("ntpath.join('//computer/share', 'a/b')", '//computer/share\\a/b')
|
tester("ntpath.join('//computer/share', 'a/b')", '//computer/share\\a/b')
|
||||||
|
|
||||||
|
tester("ntpath.join('\\\\', 'computer')", '\\\\computer')
|
||||||
|
tester("ntpath.join('\\\\computer\\', 'share')", '\\\\computer\\share')
|
||||||
|
tester("ntpath.join('\\\\computer\\share\\', 'a')", '\\\\computer\\share\\a')
|
||||||
|
tester("ntpath.join('\\\\computer\\share\\a\\', 'b')", '\\\\computer\\share\\a\\b')
|
||||||
|
|
||||||
def test_normpath(self):
|
def test_normpath(self):
|
||||||
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')
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix issue where :func:`os.path.join` added a slash when joining onto an
|
||||||
|
incomplete UNC drive with a trailing slash on Windows.
|
Loading…
Reference in New Issue