summaryrefslogtreecommitdiff
path: root/Lib/test/test_pathlib.py
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2021-04-07 23:50:13 +0100
committerGitHub <noreply@github.com>2021-04-07 23:50:13 +0100
commit3f3d82b84823eb28abeedf317bbe107bbe7f6492 (patch)
tree8b2176164b9bd84834d8381f1e2b102f8bb5f44d /Lib/test/test_pathlib.py
parentdf5dc1c7a536abc2b497cb9506f8a37949838309 (diff)
downloadcpython-git-3f3d82b84823eb28abeedf317bbe107bbe7f6492.tar.gz
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 'Lib/test/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 2643119352..0c89b6ef14 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -2609,7 +2609,7 @@ class WindowsPathTest(_BasePathTest, unittest.TestCase):
env.pop('USERNAME', None)
self.assertEqual(p1.expanduser(),
P('C:/Users/alice/My Documents'))
- self.assertRaises(KeyError, p2.expanduser)
+ self.assertRaises(RuntimeError, p2.expanduser)
env['USERNAME'] = 'alice'
self.assertEqual(p2.expanduser(),
P('C:/Users/alice/My Documents'))