Kaydet (Commit) 7f0d8886 authored tarafından Jesus Cea's avatar Jesus Cea

Closes #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'

üst d576c711
......@@ -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.
......
......@@ -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
......
......@@ -308,6 +308,7 @@ Doug Fort
John Fouhy
Martin Franklin
Robin Friedrich
Bradley Froehle
Ivan Frohne
Jim Fulton
Tadayoshi Funaba
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment