diff options
author | Barney Gale <barney.gale@gmail.com> | 2023-04-11 16:26:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 16:26:45 (GMT) |
commit | b57105ae33e1f61e6bdf0eec45c4135d067b9b22 (patch) | |
tree | 3d844292fdb3908b6226d01ff2b8602ecc405442 /Lib | |
parent | 50b4b1598411ed393f47ce7f4fffbe5b9063cd42 (diff) | |
download | cpython-b57105ae33e1f61e6bdf0eec45c4135d067b9b22.zip cpython-b57105ae33e1f61e6bdf0eec45c4135d067b9b22.tar.gz cpython-b57105ae33e1f61e6bdf0eec45c4135d067b9b22.tar.bz2 |
GH-103220: Fix `ntpath.join()` of partial UNC drive with trailing slash (GH-103221)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ntpath.py | 2 | ||||
-rw-r--r-- | Lib/test/test_ntpath.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 6e2da79..0f3674f 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -142,7 +142,7 @@ def join(path, *paths): result_path = result_path + p_path ## add separator between UNC and non-absolute path 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 + result_root + result_path except (TypeError, AttributeError, BytesWarning): diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 4e755d1..42b9587 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -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')", '\\\\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): tester("ntpath.normpath('A//////././//.//B')", r'A\B') tester("ntpath.normpath('A/./B')", r'A\B') |