summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2021-04-07 22:50:13 (GMT)
committerGitHub <noreply@github.com>2021-04-07 22:50:13 (GMT)
commit3f3d82b84823eb28abeedf317bbe107bbe7f6492 (patch)
tree8b2176164b9bd84834d8381f1e2b102f8bb5f44d /Misc
parentdf5dc1c7a536abc2b497cb9506f8a37949838309 (diff)
downloadcpython-3f3d82b84823eb28abeedf317bbe107bbe7f6492.zip
cpython-3f3d82b84823eb28abeedf317bbe107bbe7f6492.tar.gz
cpython-3f3d82b84823eb28abeedf317bbe107bbe7f6492.tar.bz2
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.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2020-03-09-20-36-07.bpo-39899.9adF3E.rst3
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2020-03-09-20-36-07.bpo-39899.9adF3E.rst b/Misc/NEWS.d/next/Library/2020-03-09-20-36-07.bpo-39899.9adF3E.rst
new file mode 100644
index 0000000..5239553
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-03-09-20-36-07.bpo-39899.9adF3E.rst
@@ -0,0 +1,3 @@
+:func:`os.path.expanduser()` now refuses to guess Windows home directories if the basename of current user's home directory does not match their username.
+
+:meth:`pathlib.Path.expanduser()` and :meth:`~pathlib.Path.home()` now consistently raise :exc:`RuntimeError` exception when a home directory cannot be resolved. Previously a :exc:`KeyError` exception could be raised on Windows when the ``"USERNAME"`` environment variable was unset.