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

Whitespace-only lines in PDB cause a line continuation when taken from history #125378

Closed
treyhunner opened this issue Oct 12, 2024 · 2 comments
Closed
Assignees
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@treyhunner
Copy link
Member

treyhunner commented Oct 12, 2024

Bug report

Bug description:

The issue happens only when pulling a line from history.

Typing 4 spaces or a Tab and hitting Enter when at the PDB prompt is interpreted the same as hitting Enter without entering whitespace.
However, grabbing a whitespace-only line from history causes a prompt/line continuatin.

To reproduce:

  1. Type if True: and hit Enter
  2. Type 4 spaces and hit Enter
  3. Type 4 spaces, print("True") and hit Enter twice
  4. Hit the up arrow 2 times
  5. Hit Enter again

After those 5 steps you will see:

image

Repeatedly hitting Enter at that point shows the same continuation prompt:

image

The new REPL had a somewhat similar issue (#118911 was part of it).

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

@treyhunner treyhunner added the type-bug An unexpected behavior, bug, or error label Oct 12, 2024
@savannahostrowski savannahostrowski added stdlib Python modules in the Lib dir 3.13 bugs and security fixes labels Oct 12, 2024
@savannahostrowski
Copy link
Member

cc: @gaogaotiantian

@gaogaotiantian
Copy link
Member

gaogaotiantian commented Oct 19, 2024

It doesn't need a repro this complicated :) The repro could be:

  1. type any multi-line statement and finish it
  2. hit <enter>

Basically the issue is, an empty line means "repeat" in pdb (inherited from cmd.Cmd), but pdb did not remember the full multi-line statement, it only remembers the first line. So equivalently, when you read the empty line from the history, you just sent a "repeat" command, and it repeated the line of the if statement - that line did not end, so pdb is expecting more code, hence the ....

Fix was straightforward - just let pdb remember the full multi-line command as the last command.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 19, 2024
…or empty line command (pythonGH-125717)

(cherry picked from commit 8f5e39d)

Co-authored-by: Tian Gao <[email protected]>
gaogaotiantian added a commit that referenced this issue Oct 19, 2024
…for empty line command (GH-125717) (#125736)

gh-125378: Trigger a repeat for the full multi-line statement for empty line command (GH-125717)
(cherry picked from commit 8f5e39d)

Co-authored-by: Tian Gao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants