Skip to content

Commit 2faa9e1

Browse files
committed
Patch #1192590: Fix pdb's "ignore" and "condition" commands so they trap the IndexError caused by passing in an invalid breakpoint number.
Will backport.
1 parent 8903208 commit 2faa9e1

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

Lib/pdb.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,11 @@ def do_condition(self, arg):
485485
cond = args[1]
486486
except:
487487
cond = None
488-
bp = bdb.Breakpoint.bpbynumber[bpnum]
488+
try:
489+
bp = bdb.Breakpoint.bpbynumber[bpnum]
490+
except IndexError:
491+
print >>self.stdout, 'Breakpoint index %r is not valid' % args[0]
492+
return
489493
if bp:
490494
bp.cond = cond
491495
if not cond:
@@ -506,7 +510,11 @@ def do_ignore(self,arg):
506510
count = int(args[1].strip())
507511
except:
508512
count = 0
509-
bp = bdb.Breakpoint.bpbynumber[bpnum]
513+
try:
514+
bp = bdb.Breakpoint.bpbynumber[bpnum]
515+
except IndexError:
516+
print >>self.stdout, 'Breakpoint index %r is not valid' % args[0]
517+
return
510518
if bp:
511519
bp.ignore = count
512520
if count > 0:

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ Core and builtins
158158
Library
159159
-------
160160

161+
- Patch #1192590: Fix pdb's "ignore" and "condition" commands so they trap
162+
the IndexError caused by passing in an invalid breakpoint number.
163+
161164
- Patch #1599845: Add an option to disable the implicit calls to server_bind()
162165
and server_activate() in the constructors for TCPServer, SimpleXMLRPCServer
163166
and DocXMLRPCServer.

0 commit comments

Comments
 (0)