Skip to content

Commit 8f5e39d

Browse files
gh-125378: Trigger a repeat for the full multi-line statement for empty line command (#125717)
1 parent 4c53b25 commit 8f5e39d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Lib/pdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ def default(self, line):
755755
else:
756756
line = line.rstrip('\r\n')
757757
buffer += '\n' + line
758+
self.lastcmd = buffer
758759
save_stdout = sys.stdout
759760
save_stdin = sys.stdin
760761
save_displayhook = sys.displayhook

Lib/test/test_pdb.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,7 +2448,12 @@ def test_pdb_multiline_statement():
24482448
... 'def f(x):',
24492449
... ' return x * 2',
24502450
... '',
2451-
... 'f(2)',
2451+
... 'val = 2',
2452+
... 'if val > 0:',
2453+
... ' val = f(val)',
2454+
... '',
2455+
... '', # empty line should repeat the multi-line statement
2456+
... 'val',
24522457
... 'c'
24532458
... ]):
24542459
... test_function()
@@ -2457,8 +2462,13 @@ def test_pdb_multiline_statement():
24572462
(Pdb) def f(x):
24582463
... return x * 2
24592464
...
2460-
(Pdb) f(2)
2461-
4
2465+
(Pdb) val = 2
2466+
(Pdb) if val > 0:
2467+
... val = f(val)
2468+
...
2469+
(Pdb)
2470+
(Pdb) val
2471+
8
24622472
(Pdb) c
24632473
"""
24642474

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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 commit comments

Comments
 (0)