From 53b542fe30467aab7b8e396a33b1466b3d70e06a Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 25 Mar 2015 16:39:58 +0200 Subject: [PATCH] Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes. --- Lib/ntpath.py | 2 +- Lib/test/test_ntpath.py | 1 + Misc/NEWS | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 11e4470a46..58951b9051 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -351,7 +351,7 @@ def expandvars(path): index = path.index('\'') res = res + '\'' + path[:index + 1] except ValueError: - res = res + path + res = res + c + path index = pathlen - 1 elif c == '%': # variable or '%' if path[index + 1:index + 2] == '%': diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 55da7e1354..b9a4c906de 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -206,6 +206,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(test_support.FS_NONASCII, 'need test_support.FS_NONASCII') def test_expandvars_nonascii(self): diff --git a/Misc/NEWS b/Misc/NEWS index 60ad651dc3..4d65d9aa2b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -21,6 +21,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(). -- 2.50.1