https://github.com/python/cpython/commit/b03281e11cca81ca80f6ada9232e8a26f2c2061a
commit: b03281e11cca81ca80f6ada9232e8a26f2c2061a
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: gaogaotiantian <[email protected]>
date: 2024-10-19T22:11:00Z
summary:

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

Co-authored-by: Tian Gao <[email protected]>

files:
A Misc/NEWS.d/next/Library/2024-10-19-01-30-40.gh-issue-125378.WTosxX.rst
M Lib/pdb.py
M Lib/test/test_pdb.py

diff --git a/Lib/pdb.py b/Lib/pdb.py
index a987ea7afebfa7..bede92623bb6f9 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -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
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index d8b9da61d0a308..e5bae8453ca61f 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -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
index 00000000000000..dc76889d3b210a
--- /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.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to