summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-07-30 08:54:49 (GMT)
committerGeorg Brandl <georg@python.org>2010-07-30 08:54:49 (GMT)
commit44f8bf941109c24d36d7d6e4dd05080a0191f3d9 (patch)
tree02259b8a3d17ce082719bd762b666f238d2d32b1 /Lib/pdb.py
parent26a0f87e28eb9c90446b23d73e78324f2d481a99 (diff)
downloadcpython-44f8bf941109c24d36d7d6e4dd05080a0191f3d9.zip
cpython-44f8bf941109c24d36d7d6e4dd05080a0191f3d9.tar.gz
cpython-44f8bf941109c24d36d7d6e4dd05080a0191f3d9.tar.bz2
#8015: fix crash when entering an empty line for breakpoint commands. Also restore environment properly when an exception occurs during the definition of commands.
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index cedd17e..e62f913 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -509,8 +509,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
return self.handle_command_def(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)
+ if not cmd:
+ return
if cmd == 'silent':
self.commands_silent[self.commands_bnum] = True
return # continue to handle other cmd def in the cmd list
@@ -518,7 +520,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.cmdqueue = []
return 1 # end of cmd list
cmdlist = self.commands[self.commands_bnum]
- if (arg):
+ if arg:
cmdlist.append(cmd+' '+arg)
else:
cmdlist.append(cmd)
@@ -561,9 +563,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
prompt_back = self.prompt
self.prompt = '(com) '
self.commands_defining = True
- self.cmdloop()
- self.commands_defining = False
- self.prompt = prompt_back
+ try:
+ self.cmdloop()
+ finally:
+ self.commands_defining = False
+ self.prompt = prompt_back
def do_break(self, arg, temporary = 0):
# break [ ([filename:]lineno | function) [, "condition"] ]