File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -266,8 +266,8 @@ def expanduser(path):
266266 root = b'/'
267267 else :
268268 root = '/'
269- userhome = userhome .rstrip (root ) or userhome
270- return userhome + path [i :]
269+ userhome = userhome .rstrip (root )
270+ return ( userhome + path [i :]) or root
271271
272272
273273# Expand paths containing shell variable substitutions.
Original file line number Diff line number Diff line change @@ -300,6 +300,7 @@ def test_expanduser(self):
300300 with support .EnvironmentVarGuard () as env :
301301 env ['HOME' ] = '/'
302302 self .assertEqual (posixpath .expanduser ("~" ), "/" )
303+ self .assertEqual (posixpath .expanduser ("~/foo" ), "/foo" )
303304 # expanduser should fall back to using the password database
304305 del env ['HOME' ]
305306 home = pwd .getpwuid (os .getuid ()).pw_dir
Original file line number Diff line number Diff line change @@ -335,6 +335,7 @@ Andrew Francis
335335Martin Franklin
336336Bruce Frederiksen
337337Robin Friedrich
338+ Bradley Froehle
338339Ivan Frohne
339340Matthias Fuchs
340341Jim Fulton
Original file line number Diff line number Diff line change @@ -139,6 +139,8 @@ Library
139139
140140- Issue #13815: TarFile.extractfile() now returns io.BufferedReader objects.
141141
142+ - Issue #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'.
143+
142144- Issue #14371: Support bzip2 in zipfile module. Patch by Serhiy Storchaka.
143145
144146- Issue #13183: Fix pdb skipping frames after hitting a breakpoint and running
You can’t perform that action at this time.
0 commit comments