[Python-checkins] cpython (3.2): Closes #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is
jesus.cea
python-checkins at python.org
Thu May 10 05:16:58 CEST 2012
http://hg.python.org/cpython/rev/e472481b6d73
changeset: 76852:e472481b6d73
branch: 3.2
parent: 76847:9de4d85e4197
user: Jesus Cea <jcea at jcea.es>
date: Thu May 10 05:10:50 2012 +0200
summary:
Closes #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'
files:
Lib/posixpath.py | 4 ++--
Lib/test/test_posixpath.py | 1 +
Misc/ACKS | 1 +
Misc/NEWS | 2 ++
4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -266,8 +266,8 @@
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.
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -298,6 +298,7 @@
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
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -308,6 +308,7 @@
John Fouhy
Martin Franklin
Robin Friedrich
+Bradley Froehle
Ivan Frohne
Jim Fulton
Tadayoshi Funaba
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -63,6 +63,8 @@
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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list