Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes.
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 25 Mar 2015 14:40:15 +0000 (16:40 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 25 Mar 2015 14:40:15 +0000 (16:40 +0200)
Lib/ntpath.py
Lib/test/test_ntpath.py
Misc/NEWS

index af3fb8746aa852cf415df3990f9a48ef6e2c65a4..992970ab1dc7bb1832835a825f37b1fd5074b52b 100644 (file)
@@ -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:
index c8d84a7467c9f00b77bd243c8f29225c3a727341..dacddded3dd7c1cb1248a5538d3e840571eeed10 100644 (file)
@@ -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):
index fb400038cfcff857f6adffe54638cbba9fa7fdc6..7075ef8d68a256967cb5cf641078278ee6e02bb2 100644 (file)
--- 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().