diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2024-10-19 21:46:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-19 21:46:57 (GMT) |
commit | 8f5e39d5c885318e3128a3e84464c098b5f79a79 (patch) | |
tree | 91291c6b4555f090add7146f3de660fb4fb2b317 | |
parent | 4c53b2577531c77193430cdcd66ad6385fcda81f (diff) | |
download | cpython-8f5e39d5c885318e3128a3e84464c098b5f79a79.zip cpython-8f5e39d5c885318e3128a3e84464c098b5f79a79.tar.gz cpython-8f5e39d5c885318e3128a3e84464c098b5f79a79.tar.bz2 |
gh-125378: Trigger a repeat for the full multi-line statement for empty line command (#125717)
-rw-r--r-- | Lib/pdb.py | 1 | ||||
-rw-r--r-- | Lib/test/test_pdb.py | 16 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2024-10-19-01-30-40.gh-issue-125378.WTosxX.rst | 1 |
3 files changed, 15 insertions, 3 deletions
@@ -755,6 +755,7 @@ class Pdb(bdb.Bdb, cmd.Cmd): else: line = line.rstrip('\r\n') buffer += '\n' + line + self.lastcmd = buffer save_stdout = sys.stdout save_stdin = sys.stdin save_displayhook = sys.displayhook diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 7e6f276..1ea93ed 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -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() @@ -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 """ diff --git a/Misc/NEWS.d/next/Library/2024-10-19-01-30-40.gh-issue-125378.WTosxX.rst b/Misc/NEWS.d/next/Library/2024-10-19-01-30-40.gh-issue-125378.WTosxX.rst new file mode 100644 index 0000000..dc76889 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-19-01-30-40.gh-issue-125378.WTosxX.rst @@ -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. |