Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44f8bf9

Browse files
committed
#8015: fix crash when entering an empty line for breakpoint commands. Also restore environment properly when an exception occurs during the definition of commands.
1 parent 26a0f87 commit 44f8bf9

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

Lib/pdb.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,18 @@ def onecmd(self, line):
509509
return self.handle_command_def(line)
510510

511511
def handle_command_def(self,line):
512-
""" Handles one command line during command list definition. """
512+
"""Handles one command line during command list definition."""
513513
cmd, arg, line = self.parseline(line)
514+
if not cmd:
515+
return
514516
if cmd == 'silent':
515517
self.commands_silent[self.commands_bnum] = True
516518
return # continue to handle other cmd def in the cmd list
517519
elif cmd == 'end':
518520
self.cmdqueue = []
519521
return 1 # end of cmd list
520522
cmdlist = self.commands[self.commands_bnum]
521-
if (arg):
523+
if arg:
522524
cmdlist.append(cmd+' '+arg)
523525
else:
524526
cmdlist.append(cmd)
@@ -561,9 +563,11 @@ def do_commands(self, arg):
561563
prompt_back = self.prompt
562564
self.prompt = '(com) '
563565
self.commands_defining = True
564-
self.cmdloop()
565-
self.commands_defining = False
566-
self.prompt = prompt_back
566+
try:
567+
self.cmdloop()
568+
finally:
569+
self.commands_defining = False
570+
self.prompt = prompt_back
567571

568572
def do_break(self, arg, temporary = 0):
569573
# break [ ([filename:]lineno | function) [, "condition"] ]

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ C-API
475475
Library
476476
-------
477477

478+
- Issue #8015: In pdb, do not crash when an empty line is entered as
479+
a breakpoint command.
480+
478481
- In pdb, allow giving a line number to the "until" command.
479482

480483
- Issue #1437051: For pdb, allow "continue" and related commands in

0 commit comments

Comments
 (0)