[Python-checkins] r71241 - in python/trunk: Lib/posixpath.py Lib/test/test_posixpath.py Misc/NEWS
georg.brandl
python-checkins at python.org
Sun Apr 5 16:48:50 CEST 2009
Author: georg.brandl
Date: Sun Apr 5 16:48:49 2009
New Revision: 71241
Log:
#5471: fix expanduser() for $HOME set to "/".
Modified:
python/trunk/Lib/posixpath.py
python/trunk/Lib/test/test_posixpath.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/posixpath.py
==============================================================================
--- python/trunk/Lib/posixpath.py (original)
+++ python/trunk/Lib/posixpath.py Sun Apr 5 16:48:49 2009
@@ -262,7 +262,7 @@
except KeyError:
return path
userhome = pwent.pw_dir
- userhome = userhome.rstrip('/')
+ userhome = userhome.rstrip('/') or userhome
return userhome + path[i:]
Modified: python/trunk/Lib/test/test_posixpath.py
==============================================================================
--- python/trunk/Lib/test/test_posixpath.py (original)
+++ python/trunk/Lib/test/test_posixpath.py Sun Apr 5 16:48:49 2009
@@ -345,6 +345,11 @@
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):
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sun Apr 5 16:48:49 2009
@@ -212,6 +212,8 @@
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.
More information about the Python-checkins
mailing list