Merge pull request #2441 from xonsh/tq

fixed triple quote issue when open triple quotes are on the last line
This commit is contained in:
Morten Enemark Lund 2017-07-16 23:09:04 +02:00 committed by GitHub
commit 075b6038da
3 changed files with 15 additions and 1 deletions

13
news/tq.rst Normal file
View file

@ -0,0 +1,13 @@
**Added:** None
**Changed:** None
**Deprecated:** None
**Removed:** None
**Fixed:**
* Fixed issue with starting triple quote strings being run as a command.
**Security:** None

View file

@ -403,6 +403,7 @@ mom"""
" --option2 value2 \\\n"
" --optionZ valueZ",
1, "echo --option1 value1 --option2 value2 --optionZ valueZ", 3),
('"""\n', 0, '"""', 1),
]
@pytest.mark.parametrize('src, idx, exp_line, exp_n', LOGICAL_LINE_CASES)

View file

@ -445,7 +445,7 @@ def get_logical_line(lines, idx):
start = idx
line = lines[idx]
open_triple = _have_open_triple_quotes(line)
while (line.endswith(linecont) or open_triple) and idx < nlines:
while (line.endswith(linecont) or open_triple) and idx < nlines - 1:
n += 1
idx += 1
if line.endswith(linecont):