diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-06 15:14:12 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-06 15:14:12 (GMT) |
commit | a993902a287a0d8ff02e2fa6e451b5277c4b4af9 (patch) | |
tree | 39af086c546f70364c2f434eecadd8c0b7df71dd /Lib/pathlib.py | |
parent | 1b8b868b84112ce6aed7e07f664b5f54a0c8f9a9 (diff) | |
download | cpython-a993902a287a0d8ff02e2fa6e451b5277c4b4af9.zip cpython-a993902a287a0d8ff02e2fa6e451b5277c4b4af9.tar.gz cpython-a993902a287a0d8ff02e2fa6e451b5277c4b4af9.tar.bz2 |
Issue #19908: pathlib now joins relative Windows paths correctly when a drive
is present. Original patch by Antoine Pitrou.
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 73bf9df..b404c1f 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -89,12 +89,16 @@ class _Flavour(object): (drive, root, parts) tuples. Return a new (drive, root, parts) tuple. """ if root2: - parts = parts2 - root = root2 + if not drv2 and drv: + return drv, root2, [drv + root2] + parts2[1:] + elif drv2: + if drv2 == drv or self.casefold(drv2) == self.casefold(drv): + # Same drive => second path is relative to the first + return drv, root, parts + parts2[1:] else: - parts = parts + parts2 - # XXX raise error if drv and drv2 are different? - return drv2 or drv, root, parts + # Second path is non-anchored (common case) + return drv, root, parts + parts2 + return drv2, root2, parts2 class _WindowsFlavour(_Flavour): |