https://github.com/python/cpython/commit/4bbb0273f23c93ee82d7f60067775c558a7d1b1b
commit: 4bbb0273f23c93ee82d7f60067775c558a7d1b1b
branch: main
author: Tian Gao <[email protected]>
committer: gaogaotiantian <[email protected]>
date: 2024-06-19T15:50:26-07:00
summary:
gh-120606: Allow EOF to exit pdb commands definition (#120607)
files:
A Misc/NEWS.d/next/Library/2024-06-16-21-33-56.gh-issue-120606.kugbwR.rst
M Lib/pdb.py
M Lib/test/test_pdb.py
diff --git a/Lib/pdb.py b/Lib/pdb.py
index ddbfb9d2bb6244..b1be207a9fa98a 100644
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -860,6 +860,9 @@ def handle_command_def(self, line):
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)
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 5edf68dc3b429b..b2b78f1ab9ecca 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -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
index 00000000000000..874823ea3486fb
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-06-16-21-33-56.gh-issue-120606.kugbwR.rst
@@ -0,0 +1 @@
+Allow users to use EOF to exit ``commands`` definition in :mod:`pdb`
_______________________________________________
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]