Skip to content

[xonsh] Coconut xontrib causes crash when using semi-separated commands #745

Closed

Description

@Starwort

Putting multiple commands on one line with semicolons (e.g. echo; echo) causes a crash with IndexError: list index out of range; the crash does not occur after xontrib unload coconut and continues to occur after xontrib load cooconut

Detailed crash log
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/xonsh/ptk_shell/shell.py", line 384, in _push
    code = self.execer.compile(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/xonsh/execer.py", line 130, in compile
    tree = self.parse(input, ctx, mode=mode, filename=filename, transform=transform)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/xonsh/execer.py", line 101, in parse
    tree = self.ctxtransformer.ctxvisit(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/xonsh/ast.py", line 376, in ctxvisit
    node = self.visit(node)
           ^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/ast.py", line 410, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/ast.py", line 486, in generic_visit
    value = self.visit(value)
            ^^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/ast.py", line 410, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/xonsh/ast.py", line 491, in visit_Expr
    newnode = self.try_subproc_toks(node)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/coconut/integrations.py", line 121, in new_try_subproc_toks
    return ctxtransformer.__class__.try_subproc_toks(ctxtransformer, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/xonsh/ast.py", line 398, in try_subproc_toks
    line, nlogical, idx = get_logical_line(self.lines, node.lineno - 1)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/starwort/.pyenv/versions/3.11.0/lib/python3.11/site-packages/xonsh/tools.py", line 581, in get_logical_line
    line = lines[idx]
           ~~~~~^^^^^
IndexError: list index out of range

From the crash log, it seems like Coconut is doing something to change the number of 'logical lines' in a way Xonsh does not expect

Thanks for your time, and your speed in fixing the last xontrib bug!

Activity

  1. added this to the v3.0.1 milestone on May 21, 2023
  2. added a commit that references this issue on May 22, 2023
    73d6e3b
  3. evhub commented on May 22, 2023

    @evhub
    Owner

    Should be fixed now as of coconut-develop>=3.0.0-post_dev8. Just pip install -U coconut-develop>=3.0.0-post_dev8.

  4. added a commit that references this issue on May 25, 2023
    2eb0cad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions