[Python-checkins] cpython (2.7): 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:59 CEST 2012
http://hg.python.org/cpython/rev/299dc54ad014
changeset: 76853:299dc54ad014
branch: 2.7
parent: 76849:d3ddbad31b3e
user: Jesus Cea <jcea at jcea.es>
date: Thu May 10 05:01:11 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
@@ -267,8 +267,8 @@
except KeyError:
return path
userhome = pwent.pw_dir
- userhome = userhome.rstrip('/') or userhome
- return userhome + path[i:]
+ userhome = userhome.rstrip('/')
+ return (userhome + path[i:]) or '/'
# 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
@@ -201,6 +201,7 @@
with test_support.EnvironmentVarGuard() as env:
env['HOME'] = '/'
self.assertEqual(posixpath.expanduser("~"), "/")
+ self.assertEqual(posixpath.expanduser("~/foo"), "/foo")
def test_normpath(self):
self.assertEqual(posixpath.normpath(""), ".")
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -274,6 +274,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
@@ -60,6 +60,8 @@
Library
-------
+- Issue #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'.
+
- Issue #13183: Fix pdb skipping frames after hitting a breakpoint and running
step. Patch by Xavier de Gaye.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list