Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-line statements in pdb #103124

Closed
gaogaotiantian opened this issue Mar 30, 2023 · 3 comments
Closed

Support multi-line statements in pdb #103124

gaogaotiantian opened this issue Mar 30, 2023 · 3 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@gaogaotiantian
Copy link
Member

gaogaotiantian commented Mar 30, 2023

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

@gaogaotiantian gaogaotiantian added the type-feature A feature request or enhancement label Mar 30, 2023
@arhadthedev arhadthedev added the stdlib Python modules in the Lib dir label Mar 30, 2023
@gaogaotiantian
Copy link
Member Author

Modified the failing test because print( is a valid command now(it will wait for the closing parenthesis). Added multiline statement tests. This is an intuitive feature so no new documentation is required.

@gaogaotiantian
Copy link
Member Author

@iritkatriel and @brandtbucher , do you think we still have a chance to merge this in for 3.12? I do think this is a significant improvement for pdb.

@brandtbucher
Copy link
Member

I agree, and I'm sorry we didn't have the time to review this for 3.12. I'm looking forward to reviewing this improvement for 3.13, though!

carljm added a commit to carljm/cpython that referenced this issue Jun 16, 2023
* main:
  pythongh-104799: PEP 695 backward compatibility for ast.unparse (python#105846)
  pythongh-105834: Add tests for calling `issubclass()` between two protocols (python#105835)
  CI: Remove docs build from Azure Pipelines (python#105823)
  pythongh-105844: Consistently use 'minor version' for X.Y versions (python#105851)
  Fix inaccuracies in "Assorted Topics" section of "Defining Extension Types" tutorial (python#104969)
  pythongh-105433: Add `pickle` tests for PEP695 (python#105443)
  bpo-44530: Document the change in MAKE_FUNCTION behavior (python#93189)
  pythonGH-103124: Multiline statement support for pdb (pythonGH-103125)
  pythonGH-105588: Add missing error checks to some obj2ast_* converters (pythonGH-105589)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants