]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-125378: Trigger a repeat for the full multi-line statement for empty line...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 19 Oct 2024 22:11:00 +0000 (00:11 +0200)
committerGitHub <noreply@github.com>
Sat, 19 Oct 2024 22:11:00 +0000 (22:11 +0000)
gh-125378: Trigger a repeat for the full multi-line statement for empty line command (GH-125717)
(cherry picked from commit 8f5e39d5c885318e3128a3e84464c098b5f79a79)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Lib/pdb.py
Lib/test/test_pdb.py
Misc/NEWS.d/next/Library/2024-10-19-01-30-40.gh-issue-125378.WTosxX.rst [new file with mode: 0644]

index a987ea7afebfa7608377ddd02643690a75717c02..bede92623bb6f9b0d09d6c8c1271babc1f989a61 100755 (executable)
@@ -750,6 +750,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
index d8b9da61d0a308e3c9ac7cec4044ca3896e8cc85..e5bae8453ca61fc21aeffa3c14a34f39d7645bf6 100644 (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
     """
 
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 (file)
index 0000000..dc76889
--- /dev/null
@@ -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.