◐ Shell
clean mode source ↗

Support multi-line statements in pdb

Feature or enhancement

Support multi-line statements in pdb just like in normal Python interactive shells

Pitch

Currently, we have this:

(Pdb) def f():
*** IndentationError: expected an indented block after function definition on line 1
(Pdb) 

We can have this:

(Pdb) def f():
...     pass
...   
(Pdb) 

The fundamental logic is handled by codeop.compile_command, we just need to port it in.

It's kind of a breaking change, as the behavior for the once failed single-line check only code could potentially work. For example, we have this in the error case check:

(Pdb) print(
*** SyntaxError: '(' was never closed"

And it won't be failing anymore as we can close it in the next line. But in general, I believe this feature has more benifits than problems.

I'll make the PR draft for now and wait for some more discussion on the matter.

Linked PRs