Skip to content

Commit b03281e

Browse files
[3.13] gh-125378: Trigger a repeat for the full multi-line statement 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]>
1 parent 9e43330 commit b03281e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Lib/pdb.py

+1
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ def default(self, line):
750750
else:
751751
line = line.rstrip('\r\n')
752752
buffer += '\n' + line
753+
self.lastcmd = buffer
753754
save_stdout = sys.stdout
754755
save_stdin = sys.stdin
755756
save_displayhook = sys.displayhook

Lib/test/test_pdb.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,12 @@ def test_pdb_multiline_statement():
22932293
... 'def f(x):',
22942294
... ' return x * 2',
22952295
... '',
2296-
... 'f(2)',
2296+
... 'val = 2',
2297+
... 'if val > 0:',
2298+
... ' val = f(val)',
2299+
... '',
2300+
... '', # empty line should repeat the multi-line statement
2301+
... 'val',
22972302
... 'c'
22982303
... ]):
22992304
... test_function()
@@ -2302,8 +2307,13 @@ def test_pdb_multiline_statement():
23022307
(Pdb) def f(x):
23032308
... return x * 2
23042309
...
2305-
(Pdb) f(2)
2306-
4
2310+
(Pdb) val = 2
2311+
(Pdb) if val > 0:
2312+
... val = f(val)
2313+
...
2314+
(Pdb)
2315+
(Pdb) val
2316+
8
23072317
(Pdb) c
23082318
"""
23092319

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)