mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
Merge pull request #2738 from xonsh/firstse
First SyntaxError no longer always reported
This commit is contained in:
commit
f19712a9d9
3 changed files with 28 additions and 0 deletions
14
news/firstse.rst
Normal file
14
news/firstse.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
**Added:** None
|
||||
|
||||
**Changed:** None
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* Fixed issue with ``SyntaxErrors`` being reported on the wrong line
|
||||
when a block of code contained multiple implicit subprocesses.
|
||||
|
||||
**Security:** None
|
|
@ -287,6 +287,18 @@ def test_eof_syntax_error():
|
|||
assert ':2:0: EOF in multi-line statement' in err
|
||||
|
||||
|
||||
def test_open_quote_syntax_error():
|
||||
script = ('#!/usr/bin/env xonsh\n\n'
|
||||
'echo "This is line 3"\n'
|
||||
'print ("This is line 4")\n'
|
||||
'x = "This is a string where I forget the closing quote on line 5\n'
|
||||
'echo "This is line 6"\n')
|
||||
out, err, rtn = run_xonsh(script, stderr=sp.PIPE)
|
||||
assert """:3:5: ('code: "This is line 3"',)""" not in err
|
||||
assert ':5:4: "' in err
|
||||
assert 'SyntaxError:' in err
|
||||
|
||||
|
||||
_bad_case = pytest.mark.skipif(ON_DARWIN or ON_WINDOWS or ON_TRAVIS,
|
||||
reason="bad platforms")
|
||||
|
||||
|
|
|
@ -177,6 +177,8 @@ class Execer(object):
|
|||
last_error_col in (e.loc.column + 1,
|
||||
e.loc.column)):
|
||||
raise original_error from None
|
||||
elif last_error_line != e.loc.lineno:
|
||||
original_error = e
|
||||
last_error_col = e.loc.column
|
||||
last_error_line = e.loc.lineno
|
||||
idx = last_error_line - 1
|
||||
|
|
Loading…
Add table
Reference in a new issue