]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-39899: os.path.expanduser(): don't guess other Windows users' home directories...
authorBarney Gale <barney.gale@gmail.com>
Wed, 7 Apr 2021 22:50:13 +0000 (23:50 +0100)
committerGitHub <noreply@github.com>
Wed, 7 Apr 2021 22:50:13 +0000 (23:50 +0100)
commit3f3d82b84823eb28abeedf317bbe107bbe7f6492
tree8b2176164b9bd84834d8381f1e2b102f8bb5f44d
parentdf5dc1c7a536abc2b497cb9506f8a37949838309
bpo-39899: os.path.expanduser(): don't guess other Windows users' home directories if the basename of the current user's home directory doesn't match their username. (GH-18841)

This makes `ntpath.expanduser()` match `pathlib.Path.expanduser()` in this regard, and is more in line with `posixpath.expanduser()`'s cautious approach.

Also remove the near-duplicate implementation of `expanduser()` in pathlib, and by doing so fix a bug where KeyError could be raised when expanding another user's home directory.
Doc/library/os.path.rst
Doc/library/pathlib.rst
Lib/ntpath.py
Lib/pathlib.py
Lib/test/test_ntpath.py
Lib/test/test_pathlib.py
Misc/NEWS.d/next/Library/2020-03-09-20-36-07.bpo-39899.9adF3E.rst [new file with mode: 0644]