summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-05-10 03:16:41 (GMT)
committerJesus Cea <jcea@jcea.es>2012-05-10 03:16:41 (GMT)
commitb58ab2c6aa96a9320de2d4b2966e0e968ce5c524 (patch)
tree68d91f4bd84f4ce4be15692eabc5300f4e5e0539
parent3b1a74a9c39457112a5028775a795bd178ef072a (diff)
parent7f0d88860f04d6411dbc1218bf78d9ec5ce153b8 (diff)
downloadcpython-b58ab2c6aa96a9320de2d4b2966e0e968ce5c524.zip
cpython-b58ab2c6aa96a9320de2d4b2966e0e968ce5c524.tar.gz
cpython-b58ab2c6aa96a9320de2d4b2966e0e968ce5c524.tar.bz2
MERGE: Closes #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'
-rw-r--r--Lib/posixpath.py4
-rw-r--r--Lib/test/test_posixpath.py1
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS2
4 files changed, 6 insertions, 2 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index c9829e1..9570a36 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -266,8 +266,8 @@ def expanduser(path):
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
index 709ef04..daebeaa 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -300,6 +300,7 @@ class PosixPathTest(unittest.TestCase):
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
index 6e38038..c7dc2f4 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -335,6 +335,7 @@ Andrew Francis
Martin Franklin
Bruce Frederiksen
Robin Friedrich
+Bradley Froehle
Ivan Frohne
Matthias Fuchs
Jim Fulton
diff --git a/Misc/NEWS b/Misc/NEWS
index 0850336..9109bf4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -139,6 +139,8 @@ Library
- Issue #13815: TarFile.extractfile() now returns io.BufferedReader objects.
+- Issue #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'.
+
- Issue #14371: Support bzip2 in zipfile module. Patch by Serhiy Storchaka.
- Issue #13183: Fix pdb skipping frames after hitting a breakpoint and running