mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
bpo-44682: Handle invalid arg to pdb's "commands" directive (#27252)
This commit is contained in:
parent
cb1d76f10a
commit
53b9458f2e
3 changed files with 19 additions and 0 deletions
|
|
@ -640,6 +640,12 @@ def do_commands(self, arg):
|
|||
except:
|
||||
self.error("Usage: commands [bnum]\n ...\n end")
|
||||
return
|
||||
try:
|
||||
self.get_bpbynumber(bnum)
|
||||
except ValueError as err:
|
||||
self.error('cannot set commands: %s' % err)
|
||||
return
|
||||
|
||||
self.commands_bnum = bnum
|
||||
# Save old definitions for the case of a keyboard interrupt.
|
||||
if bnum in self.commands:
|
||||
|
|
|
|||
|
|
@ -260,6 +260,9 @@ def test_pdb_breakpoint_commands():
|
|||
... 'tbreak 5',
|
||||
... 'continue', # will stop at temporary breakpoint
|
||||
... 'break', # make sure breakpoint is gone
|
||||
... 'commands 10', # out of range
|
||||
... 'commands a', # display help
|
||||
... 'commands 4', # already deleted
|
||||
... 'continue',
|
||||
... ]):
|
||||
... test_function()
|
||||
|
|
@ -319,6 +322,14 @@ def test_pdb_breakpoint_commands():
|
|||
> <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(5)test_function()
|
||||
-> print(3)
|
||||
(Pdb) break
|
||||
(Pdb) commands 10
|
||||
*** cannot set commands: Breakpoint number 10 out of range
|
||||
(Pdb) commands a
|
||||
*** Usage: commands [bnum]
|
||||
...
|
||||
end
|
||||
(Pdb) commands 4
|
||||
*** cannot set commands: Breakpoint 4 already deleted
|
||||
(Pdb) continue
|
||||
3
|
||||
4
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Change the :mod:`pdb` *commands* directive to disallow setting commands
|
||||
for an invalid breakpoint and to display an appropriate error.
|
||||
Loading…
Add table
Add a link
Reference in a new issue