Commit 44f8bf94 authored by Georg Brandl's avatar Georg Brandl

#8015: fix crash when entering an empty line for breakpoint commands. Also...

#8015: fix crash when entering an empty line for breakpoint commands.  Also restore environment properly when an exception occurs during the definition of commands.
parent 26a0f87e
...@@ -509,8 +509,10 @@ class Pdb(bdb.Bdb, cmd.Cmd): ...@@ -509,8 +509,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
return self.handle_command_def(line) return self.handle_command_def(line)
def handle_command_def(self,line): def handle_command_def(self,line):
""" Handles one command line during command list definition. """ """Handles one command line during command list definition."""
cmd, arg, line = self.parseline(line) cmd, arg, line = self.parseline(line)
if not cmd:
return
if cmd == 'silent': if cmd == 'silent':
self.commands_silent[self.commands_bnum] = True self.commands_silent[self.commands_bnum] = True
return # continue to handle other cmd def in the cmd list return # continue to handle other cmd def in the cmd list
...@@ -518,7 +520,7 @@ class Pdb(bdb.Bdb, cmd.Cmd): ...@@ -518,7 +520,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.cmdqueue = [] self.cmdqueue = []
return 1 # end of cmd list return 1 # end of cmd list
cmdlist = self.commands[self.commands_bnum] cmdlist = self.commands[self.commands_bnum]
if (arg): if arg:
cmdlist.append(cmd+' '+arg) cmdlist.append(cmd+' '+arg)
else: else:
cmdlist.append(cmd) cmdlist.append(cmd)
...@@ -561,9 +563,11 @@ class Pdb(bdb.Bdb, cmd.Cmd): ...@@ -561,9 +563,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
prompt_back = self.prompt prompt_back = self.prompt
self.prompt = '(com) ' self.prompt = '(com) '
self.commands_defining = True self.commands_defining = True
self.cmdloop() try:
self.commands_defining = False self.cmdloop()
self.prompt = prompt_back finally:
self.commands_defining = False
self.prompt = prompt_back
def do_break(self, arg, temporary = 0): def do_break(self, arg, temporary = 0):
# break [ ([filename:]lineno | function) [, "condition"] ] # break [ ([filename:]lineno | function) [, "condition"] ]
......
...@@ -475,6 +475,9 @@ C-API ...@@ -475,6 +475,9 @@ C-API
Library Library
------- -------
- Issue #8015: In pdb, do not crash when an empty line is entered as
a breakpoint command.
- In pdb, allow giving a line number to the "until" command. - In pdb, allow giving a line number to the "until" command.
- Issue #1437051: For pdb, allow "continue" and related commands in - Issue #1437051: For pdb, allow "continue" and related commands in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment