Xonsh: `\` fails to separate lines

Created on 11 Jun 2018  路  6Comments  路  Source: xonsh/xonsh

I tried

git pull upstream master \
or git pull origin master \
or git pull @(rc.remote) master \
or git pull @(rc.remote) @(rc.branch) \
or git pull

and xonsh was not happy:

../../mc/envs/regro/lib/python3.6/site-packages/_pytest/python.py:403: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
../../mc/envs/regro/lib/python3.6/site-packages/py/_path/local.py:668: in pyimport
    __import__(modname)
<frozen importlib._bootstrap>:971: in _find_and_load
    ???
<frozen importlib._bootstrap>:955: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:656: in _load_unlocked
    ???
<frozen importlib._bootstrap>:626: in _load_backward_compatible
    ???
../../mc/envs/regro/lib/python3.6/site-packages/_pytest/assertion/rewrite.py:212: in load_module
    py.builtin.exec_(co, mod.__dict__)
tests/test_validate.py:8: in <module>
    from regolith.main import main
regolith/main.py:11: in <module>
    from regolith.database import connect
<frozen importlib._bootstrap>:971: in _find_and_load
    ???
<frozen importlib._bootstrap>:955: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:665: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:674: in exec_module
    ???
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/__amalgam__.py:20145: in get_code
    code = execer.compile(src, glbs=ctx, locs=ctx)
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/__amalgam__.py:19877: in compile
    transform=transform)
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/__amalgam__.py:19846: in parse
    tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/__amalgam__.py:19946: in _parse_ctx_free
    raise original_error from None
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/__amalgam__.py:19933: in _parse_ctx_free
    debug_level=(self.debug_level > 2))
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/parsers/base.py:349: in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
../../mc/envs/regro/lib/python3.6/site-packages/ply/yacc.py:331: in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
../../mc/envs/regro/lib/python3.6/site-packages/ply/yacc.py:1199: in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
../../mc/envs/regro/lib/python3.6/site-packages/ply/yacc.py:193: in call_errorfunc
    r = errorfunc(token)
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/parsers/base.py:2741: in p_error
    column=p.lexpos))
../../mc/envs/regro/lib/python3.6/site-packages/xonsh/parsers/base.py:482: in _parse_error
    raise err
E     File "<string>", line None
E   SyntaxError: /home/christopher/dev/regolith/regolith/database.xsh:34:16: ('code: pull',)
E               git pull upstream master \
bug

Most helpful comment

I can confirm that:

echo 'a' \
and echo 'b'

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/xonsh/ptk/shell.py", line 138, in _push
    locs=None)
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20084, in compile
    transform=transform)
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20053, in parse
    tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20153, in _parse_ctx_free
    raise original_error from None
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20140, in _parse_ctx_free
    debug_level=(self.debug_level > 2))
  File "/usr/lib/python3.7/site-packages/xonsh/parsers/base.py", line 349, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File "/usr/lib/python3.7/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/lib/python3.7/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/usr/lib/python3.7/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/usr/lib/python3.7/site-packages/xonsh/parsers/base.py", line 2760, in p_error
    column=p.lexpos))
  File "/usr/lib/python3.7/site-packages/xonsh/parsers/base.py", line 482, in _parse_error
    raise err
  File "<string>", line None
SyntaxError: <xonsh-code>:2:10: ("code: 'b'",)
 and echo 'b'
          ^
xonfig
+------------------+-----------------+
| xonsh            | 0.7.2           |
| Python           | 3.7.0           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 1.0.15          |
| shell type       | prompt_toolkit1 |
| pygments         | 2.2.0           |
| on posix         | True            |
| on linux         | True            |
| distro           | arch            |
| on darwin        | False           |
| on windows       | False           |
| on cygwin        | False           |
| on msys2         | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
+------------------+-----------------+

All 6 comments

Using xonsh/0.6.5

Thanks for reporting @CJ-Wright! Can you provide a minimal example, probably with echo, or something that doesn't touch a git repo? Thanks!

I can confirm that:

echo 'a' \
and echo 'b'

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/xonsh/ptk/shell.py", line 138, in _push
    locs=None)
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20084, in compile
    transform=transform)
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20053, in parse
    tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20153, in _parse_ctx_free
    raise original_error from None
  File "/usr/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 20140, in _parse_ctx_free
    debug_level=(self.debug_level > 2))
  File "/usr/lib/python3.7/site-packages/xonsh/parsers/base.py", line 349, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File "/usr/lib/python3.7/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/lib/python3.7/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/usr/lib/python3.7/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/usr/lib/python3.7/site-packages/xonsh/parsers/base.py", line 2760, in p_error
    column=p.lexpos))
  File "/usr/lib/python3.7/site-packages/xonsh/parsers/base.py", line 482, in _parse_error
    raise err
  File "<string>", line None
SyntaxError: <xonsh-code>:2:10: ("code: 'b'",)
 and echo 'b'
          ^
xonfig
+------------------+-----------------+
| xonsh            | 0.7.2           |
| Python           | 3.7.0           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 1.0.15          |
| shell type       | prompt_toolkit1 |
| pygments         | 2.2.0           |
| on posix         | True            |
| on linux         | True            |
| distro           | arch            |
| on darwin        | False           |
| on windows       | False           |
| on cygwin        | False           |
| on msys2         | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
+------------------+-----------------+

Thanks @laloch - I can reproduce your example.

It seems to only be transforming the first line:

scopatz@artemis ~ $ $XONSH_DEBUG = 2 
scopatz@artemis ~ $ echo a \ 
`路.,赂,.路*炉`路.,赂,.路* and echo b 
`路.,赂,.路*炉`路.,赂,.路*          
<xonsh-code>:1:5:8 - echo a and echo b
<xonsh-code>:1:5:8 + ![echo a] and echo b

Potential fix is now available in #2795.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

74th picture 74th  路  4Comments

blueray453 picture blueray453  路  5Comments

daniel-shimon picture daniel-shimon  路  5Comments

ahundt picture ahundt  路  6Comments

ErickTucto picture ErickTucto  路  3Comments