[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 8f5e39d5c8)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
Miss Islington (bot) 2024-10-20 00:11:00 +02:00 committed by GitHub
parent 9e433304c4
commit b03281e11c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 3 deletions

View File

@ -750,6 +750,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

View File

@ -2293,7 +2293,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()
@ -2302,8 +2307,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
"""

View File

@ -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.