Skip to content

Commit

Permalink
pythongh-125378: Trigger a repeat for the full multi-line statement f…
Browse files Browse the repository at this point in the history
…or empty line command (python#125717)
  • Loading branch information
gaogaotiantian authored Oct 19, 2024
1 parent 4c53b25 commit 8f5e39d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ def default(self, line):
else:
line = line.rstrip('\r\n')
buffer += '\n' + line
self.lastcmd = buffer
save_stdout = sys.stdout
save_stdin = sys.stdin
save_displayhook = sys.displayhook
Expand Down
16 changes: 13 additions & 3 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,12 @@ def test_pdb_multiline_statement():
... 'def f(x):',
... ' return x * 2',
... '',
... 'f(2)',
... 'val = 2',
... 'if val > 0:',
... ' val = f(val)',
... '',
... '', # empty line should repeat the multi-line statement
... 'val',
... 'c'
... ]):
... test_function()
Expand All @@ -2457,8 +2462,13 @@ def test_pdb_multiline_statement():
(Pdb) def f(x):
... return x * 2
...
(Pdb) f(2)
4
(Pdb) val = 2
(Pdb) if val > 0:
... val = f(val)
...
(Pdb)
(Pdb) val
8
(Pdb) c
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the bug in :mod:`pdb` where after a multi-line command, an empty line repeats the first line of the multi-line command, instead of the full command.

0 comments on commit 8f5e39d

Please sign in to comment.