mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-94909: fix joining of absolute and relative Windows paths in pathlib (GH-95450)
Have pathlib use `os.path.join()` to join arguments to the `PurePath` initialiser, which fixes a minor bug when handling relative paths with drives. Previously: ```python >>> from pathlib import PureWindowsPath >>> a = 'C:/a/b' >>> b = 'C:x/y' >>> PureWindowsPath(a, b) PureWindowsPath('C:x/y') ``` Now: ```python >>> PureWindowsPath(a, b) PureWindowsPath('C:/a/b/x/y') ```
This commit is contained in:
parent
a965db37f2
commit
187949ebf2
3 changed files with 14 additions and 33 deletions
|
@ -136,6 +136,10 @@ class NTFlavourTest(_BaseFlavourTest, unittest.TestCase):
|
|||
check(['a', '/b', 'c'], ('', '\\', ['\\', 'b', 'c']))
|
||||
check(['Z:/a', '/b', 'c'], ('Z:', '\\', ['Z:\\', 'b', 'c']))
|
||||
check(['//?/Z:/a', '/b', 'c'], ('\\\\?\\Z:', '\\', ['\\\\?\\Z:\\', 'b', 'c']))
|
||||
# Joining with the same drive => the first path is appended to if
|
||||
# the second path is relative.
|
||||
check(['c:/a/b', 'c:x/y'], ('c:', '\\', ['c:\\', 'a', 'b', 'x', 'y']))
|
||||
check(['c:/a/b', 'c:/x/y'], ('c:', '\\', ['c:\\', 'x', 'y']))
|
||||
|
||||
def test_splitroot(self):
|
||||
f = self.flavour.splitroot
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue