Skip to content

Interactive debugger console crashes on syntax errors on Python 3.13+ #29

Description

@amol-

Goal

Make the interactive debugger console render a syntax error page instead of
raising, on Python 3.13 and newer.

Done when: evaluating an invalid expression (for example 1 +) in the
debugger console returns the rendered "Syntax Error" traceback HTML on every
supported Python version (3.9 through 3.14), and a test covers it.

Reproduction:

from backlash.console import Console
Console({}, {}, None).eval('1 +')

Current behaviour:

  • Python 3.9 - 3.12: returns the expected <h3>Syntax Error</h3> page.
  • Python 3.13 / 3.14: raises
    TypeError: _InteractiveConsole.showsyntaxerror() got an unexpected keyword argument 'source'.

Cause: _InteractiveConsole.showsyntaxerror overrides the stdlib method with
the signature (self, filename=None). Since Python 3.13,
code.InteractiveInterpreter.runsource calls
self.showsyntaxerror(filename, source=source), so the override no longer
matches its caller.

Why

Any user who mistypes an expression in the in-browser debugger console gets an
unhandled exception instead of the error page, on the two most recent Python
releases. Typing a malformed expression is a routine action in an interactive
console, so this is likely to be hit on first use.

No test currently covers this path, so CI is green despite the breakage.

References

  • backlash/console.py (_InteractiveConsole.showsyntaxerror, _InteractiveConsole.runsource)
  • stdlib code.InteractiveInterpreter.runsource signature change in Python 3.13
  • tests/test_console.py may be a natural home for a regression test

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions