Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

cpython (2.7): Closes #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

May 9, 2012, 8:16 PM

Post #1 of 1 (46 views)
Permalink
cpython (2.7): Closes #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is

http://hg.python.org/cpython/rev/299dc54ad014
changeset: 76853:299dc54ad014
branch: 2.7
parent: 76849:d3ddbad31b3e
user: Jesus Cea <jcea [at] jcea>
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

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.