]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-94909: fix joining of absolute and relative Windows paths in pathlib (GH-95450)
authorBarney Gale <barney.gale@gmail.com>
Fri, 12 Aug 2022 21:23:41 +0000 (22:23 +0100)
committerGitHub <noreply@github.com>
Fri, 12 Aug 2022 21:23:41 +0000 (14:23 -0700)
commit187949ebf2ae36fcf0817a06f4a7637d0a8b7fc5
tree97e2247dba696d69d682cefedf05d760c926bb07
parenta965db37f27ffb232312bc13d9a509f0d93fcd20
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')
```
Lib/pathlib.py
Lib/test/test_pathlib.py
Misc/NEWS.d/next/Library/2022-07-29-20-58-37.gh-issue-94909.YjMusj.rst [new file with mode: 0644]