Kaydet (Commit) 3f0ef202 authored tarafından Georg Brandl's avatar Georg Brandl

#5471: fix expanduser() for $HOME set to "/".

üst a7ec0726
......@@ -262,7 +262,7 @@ def expanduser(path):
except KeyError:
return path
userhome = pwent.pw_dir
userhome = userhome.rstrip('/')
userhome = userhome.rstrip('/') or userhome
return userhome + path[i:]
......
......@@ -345,6 +345,11 @@ class PosixPathTest(unittest.TestCase):
self.assert_(isinstance(posixpath.expanduser("~root/"), 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)
def test_expandvars(self):
......
......@@ -212,6 +212,8 @@ Core and Builtins
Library
-------
- Issue 5471: Fix os.path.expanduser() for $HOME set to '/'.
- Issue 1326077: fix the formatting of SyntaxErrors by the traceback module.
- Issue 1726172: fix IndexError in the case of and empty response in ftplib.
......
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