Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b87ae0

Browse files
Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes.
1 parent 81f241a commit 1b87ae0

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/ntpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def expandvars(path):
400400
index = path.index(c)
401401
res += c + path[:index + 1]
402402
except ValueError:
403-
res += path
403+
res += c + path
404404
index = pathlen - 1
405405
elif c == percent: # variable or '%'
406406
if path[index + 1:index + 2] == percent:

Lib/test/test_ntpath.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def test_expandvars(self):
237237
tester('ntpath.expandvars("%?bar%")', "%?bar%")
238238
tester('ntpath.expandvars("%foo%%bar")', "bar%bar")
239239
tester('ntpath.expandvars("\'%foo%\'%bar")', "\'%foo%\'%bar")
240+
tester('ntpath.expandvars("bar\'%foo%")', "bar\'%foo%")
240241

241242
@unittest.skipUnless(support.FS_NONASCII, 'need support.FS_NONASCII')
242243
def test_expandvars_nonascii(self):

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Core and Builtins
1818
Library
1919
-------
2020

21+
- Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes.
22+
2123
- Issue #21802: The reader in BufferedRWPair now is closed even when closing
2224
writer failed in BufferedRWPair.close().
2325

0 commit comments

Comments
 (0)