summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/posixpath.py4
-rw-r--r--Lib/test/test_posixpath.py1
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS2
4 files changed, 6 insertions, 2 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index c9829e18d0..9570a364a0 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -266,8 +266,8 @@ def expanduser(path):
root = b'/'
else:
root = '/'
- userhome = userhome.rstrip(root) or userhome
- return userhome + path[i:]
+ userhome = userhome.rstrip(root)
+ return (userhome + path[i:]) or root
# Expand paths containing shell variable substitutions.
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index bb4559c4ab..a7a3e4aa12 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -298,6 +298,7 @@ class PosixPathTest(unittest.TestCase):
with support.EnvironmentVarGuard() as env:
env['HOME'] = '/'
self.assertEqual(posixpath.expanduser("~"), "/")
+ self.assertEqual(posixpath.expanduser("~/foo"), "/foo")
# expanduser should fall back to using the password database
del env['HOME']
home = pwd.getpwuid(os.getuid()).pw_dir
diff --git a/Misc/ACKS b/Misc/ACKS
index 6d8b6dddd2..780c06fd5e 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -308,6 +308,7 @@ Doug Fort
John Fouhy
Martin Franklin
Robin Friedrich
+Bradley Froehle
Ivan Frohne
Jim Fulton
Tadayoshi Funaba
diff --git a/Misc/NEWS b/Misc/NEWS
index b6bc463a5d..c4901b02a7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -63,6 +63,8 @@ Core and Builtins
Library
-------
+- Issue #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'.
+
- Issue #14741: Fix missing support for Ellipsis ('...') in parser module.
- Issue #14697: Fix missing support for set displays and set comprehensions in