mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
#5471: fix expanduser() for $HOME set to "/".
This commit is contained in:
parent
a7ec0726e2
commit
3f0ef20269
3 changed files with 8 additions and 1 deletions
|
@ -262,7 +262,7 @@ def expanduser(path):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return path
|
return path
|
||||||
userhome = pwent.pw_dir
|
userhome = pwent.pw_dir
|
||||||
userhome = userhome.rstrip('/')
|
userhome = userhome.rstrip('/') or userhome
|
||||||
return userhome + path[i:]
|
return userhome + path[i:]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -345,6 +345,11 @@ class PosixPathTest(unittest.TestCase):
|
||||||
self.assert_(isinstance(posixpath.expanduser("~root/"), basestring))
|
self.assert_(isinstance(posixpath.expanduser("~root/"), basestring))
|
||||||
self.assert_(isinstance(posixpath.expanduser("~foo/"), basestring))
|
self.assert_(isinstance(posixpath.expanduser("~foo/"), basestring))
|
||||||
|
|
||||||
|
orig_home = os.environ['HOME']
|
||||||
|
os.environ['HOME'] = '/'
|
||||||
|
self.assertEqual(posixpath.expanduser("~"), "/")
|
||||||
|
os.environ['HOME'] = orig_home
|
||||||
|
|
||||||
self.assertRaises(TypeError, posixpath.expanduser)
|
self.assertRaises(TypeError, posixpath.expanduser)
|
||||||
|
|
||||||
def test_expandvars(self):
|
def test_expandvars(self):
|
||||||
|
|
|
@ -212,6 +212,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue 5471: Fix os.path.expanduser() for $HOME set to '/'.
|
||||||
|
|
||||||
- Issue 1326077: fix the formatting of SyntaxErrors by the traceback module.
|
- Issue 1326077: fix the formatting of SyntaxErrors by the traceback module.
|
||||||
|
|
||||||
- Issue 1726172: fix IndexError in the case of and empty response in ftplib.
|
- Issue 1726172: fix IndexError in the case of and empty response in ftplib.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue