Skip to content

Commit 4bbb027

Browse files
gh-120606: Allow EOF to exit pdb commands definition (#120607)
1 parent 1e48156 commit 4bbb027

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Lib/pdb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ def handle_command_def(self, line):
860860
return False # continue to handle other cmd def in the cmd list
861861
elif cmd == 'end':
862862
return True # end of cmd list
863+
elif cmd == 'EOF':
864+
print('')
865+
return True # end of cmd list
863866
cmdlist = self.commands[self.commands_bnum]
864867
if arg:
865868
cmdlist.append(cmd+' '+arg)

Lib/test/test_pdb.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ def test_pdb_breakpoint_commands():
258258
... 'clear 3',
259259
... 'break',
260260
... 'condition 1',
261+
... 'commands 1',
262+
... 'EOF', # Simulate Ctrl-D/Ctrl-Z from user, should end input
261263
... 'enable 1',
262264
... 'clear 1',
263265
... 'commands 2',
@@ -313,6 +315,9 @@ def test_pdb_breakpoint_commands():
313315
2 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
314316
(Pdb) condition 1
315317
Breakpoint 1 is now unconditional.
318+
(Pdb) commands 1
319+
(com) EOF
320+
<BLANKLINE>
316321
(Pdb) enable 1
317322
Enabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
318323
(Pdb) clear 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow users to use EOF to exit ``commands`` definition in :mod:`pdb`

0 commit comments

Comments
 (0)