Skip to content

Infinite loop on syntax errors #10

Description

@nahoj

When readable-traceback is loaded from an rc file, any syntax error (e.g. typing { or echo {) causes an infinite loop that freezes the shell.

Cause

The __flush function in readable-traceback.xsh (line 40) contains:

rep = lambda s: '' if '__amalgam__.py' in s or 'readable-traceback.xsh' in s else s+'\n'

xonsh compiles '__amalgam__.py' in s or ... as a subprocess command rather than a Python expression. So every call to __flush tries to execute __amalgam__.py as a shell command.

When a syntax error occurs → _print_exceptionbacktrace.hook__flush → subprocess __amalgam__.py → command not found → _print_exception → loop.

However, this doesn't happen if xontrib load readable-traceback is run in interactive mode, because then it doesn't replace ptk_shell.print_exception.

Reproduction

Without the xontrib:

@ {

xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
  File "<stdin>", line 1
    {
    ^
SyntaxError: EOF in multi-line statement

With it:

 @ {

[infinite loop]
Traceback (most recent call last):
[nothing]

Tested on xonsh 0.22.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions