summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-25 14:40:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-25 14:40:15 (GMT)
commit1b87ae0c910e4bcf652bd45a2c8c62ff11606b47 (patch)
treefe36926683cf8b549dd4251f00ef5f645e715c9c
parent81f241ab2e19db9e421a300c00f9fb1c4e0003df (diff)
downloadcpython-1b87ae0c910e4bcf652bd45a2c8c62ff11606b47.zip
cpython-1b87ae0c910e4bcf652bd45a2c8c62ff11606b47.tar.gz
cpython-1b87ae0c910e4bcf652bd45a2c8c62ff11606b47.tar.bz2
Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes.
-rw-r--r--Lib/ntpath.py2
-rw-r--r--Lib/test/test_ntpath.py1
-rw-r--r--Misc/NEWS2
3 files changed, 4 insertions, 1 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index af3fb87..992970a 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -400,7 +400,7 @@ def expandvars(path):
index = path.index(c)
res += c + path[:index + 1]
except ValueError:
- res += path
+ res += c + path
index = pathlen - 1
elif c == percent: # variable or '%'
if path[index + 1:index + 2] == percent:
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index c8d84a7..dacddde 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -237,6 +237,7 @@ class TestNtpath(unittest.TestCase):
tester('ntpath.expandvars("%?bar%")', "%?bar%")
tester('ntpath.expandvars("%foo%%bar")', "bar%bar")
tester('ntpath.expandvars("\'%foo%\'%bar")', "\'%foo%\'%bar")
+ tester('ntpath.expandvars("bar\'%foo%")', "bar\'%foo%")
@unittest.skipUnless(support.FS_NONASCII, 'need support.FS_NONASCII')
def test_expandvars_nonascii(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index fb40003..7075ef8 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,8 @@ Core and Builtins
Library
-------
+- Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes.
+
- Issue #21802: The reader in BufferedRWPair now is closed even when closing
writer failed in BufferedRWPair.close().