TurboGears / TurboGears/backlash
Interactive debugger console crashes on incomplete or multi-line input
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Goal
Make the interactive debugger console handle incomplete input instead of
raising.
Done when: evaluating an incomplete statement (for example if True:) in the
debugger console produces a sensible continuation/error response rather than an
exception, on every supported Python version, and a test covers it.
Reproduction:
from backlash.console import Console
Console({}, {}, None).eval('if True:')
Current behaviour, reproduced on Python 3.9, 3.13 and 3.14 alike:
AttributeError: 'NoneType' object has no attribute 'co_consts'
Cause: _wrap_compiler wraps console.compile and unconditionally calls
console.loader.register(code, source) with the result. For incomplete input,
codeop legitimately returns None to signal "needs more input", and
_ConsoleLoader.register then dereferences code.co_consts.
A guard for code is None in the wrapper (or in register) appears to be the
smallest fix, but the "needs more input" case then also has to be represented
in the console response.
Why
This is not version-specific: it affects every supported Python, so it is a
long-standing break rather than a recent regression. Any multi-line input in
the in-browser console (if, for, def, try, ...) raises instead of being
handled, which makes the console unusable for anything beyond single
expressions.
No test currently covers this path.
References
backlash/console.py(_wrap_compiler,_ConsoleLoader.register,_InteractiveConsole.runsource)- stdlib
codeop"needs more input" contract (compile_commandreturningNone) tests/test_console.pymay be a natural home for a regression test
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in backlash/console.py by tracing _wrap_compiler, _ConsoleLoader.register, and _InteractiveConsole.runsource, then inspect the stdlib codeop contract for compile_command returning None. Add a regression test in tests/test_console.py for incomplete input and run the console tests across supported Python versions. Done means incomplete and multi-line input receives a continuation or error response without raising.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100