]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120606: Allow EOF to exit pdb commands definition (#120607)
authorTian Gao <gaogaotiantian@hotmail.com>
Wed, 19 Jun 2024 22:50:26 +0000 (15:50 -0700)
committerGitHub <noreply@github.com>
Wed, 19 Jun 2024 22:50:26 +0000 (15:50 -0700)
Lib/pdb.py
Lib/test/test_pdb.py
Misc/NEWS.d/next/Library/2024-06-16-21-33-56.gh-issue-120606.kugbwR.rst [new file with mode: 0644]

index ddbfb9d2bb6244c1e66e2a416353c6d069f88c71..b1be207a9fa98a0f19f25f614c7f3c0ef204506b 100644 (file)
@@ -860,6 +860,9 @@ class Pdb(bdb.Bdb, cmd.Cmd):
             return False  # continue to handle other cmd def in the cmd list
         elif cmd == 'end':
             return True  # end of cmd list
+        elif cmd == 'EOF':
+            print('')
+            return True  # end of cmd list
         cmdlist = self.commands[self.commands_bnum]
         if arg:
             cmdlist.append(cmd+' '+arg)
index 5edf68dc3b429b7ac2cbf8ecacc90c8ae86c17a4..b2b78f1ab9eccafea8c30178c1a23827b8d4ce66 100644 (file)
@@ -258,6 +258,8 @@ def test_pdb_breakpoint_commands():
     ...     'clear 3',
     ...     'break',
     ...     'condition 1',
+    ...     'commands 1',
+    ...     'EOF',       # Simulate Ctrl-D/Ctrl-Z from user, should end input
     ...     'enable 1',
     ...     'clear 1',
     ...     'commands 2',
@@ -313,6 +315,9 @@ def test_pdb_breakpoint_commands():
     2   breakpoint   keep yes   at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
     (Pdb) condition 1
     Breakpoint 1 is now unconditional.
+    (Pdb) commands 1
+    (com) EOF
+    <BLANKLINE>
     (Pdb) enable 1
     Enabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
     (Pdb) clear 1
diff --git a/Misc/NEWS.d/next/Library/2024-06-16-21-33-56.gh-issue-120606.kugbwR.rst b/Misc/NEWS.d/next/Library/2024-06-16-21-33-56.gh-issue-120606.kugbwR.rst
new file mode 100644 (file)
index 0000000..874823e
--- /dev/null
@@ -0,0 +1 @@
+Allow users to use EOF to exit ``commands`` definition in :mod:`pdb`