diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2003-05-22 14:46:12 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2003-05-22 14:46:12 (GMT) |
commit | b1f8bab6542635cd32dfbebde3839f86819548ab (patch) | |
tree | ed4292f4a173c00230cb0e8bdd131de356ea7eee | |
parent | 35c6cd09056cc9de9fc6b0d962c2fecb81b94b08 (diff) | |
download | cpython-b1f8bab6542635cd32dfbebde3839f86819548ab.zip cpython-b1f8bab6542635cd32dfbebde3839f86819548ab.tar.gz cpython-b1f8bab6542635cd32dfbebde3839f86819548ab.tar.bz2 |
[Bug #741171] pdb crashes when enabling a non-existing breakpoint
Check the supplied breakpoint number more carefully.
(Incompatibility: before this patch, "enable -1" would enable
the last breakpoint on the list; now -1 is not a legal ID. Not sure
anyone would ever use negative indices...)
2.2 bugfix candidate, assuming making -1 illegal isn't considered a problem.
-rwxr-xr-x | Lib/pdb.py | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -375,14 +375,34 @@ class Pdb(bdb.Bdb, cmd.Cmd): def do_enable(self, arg): args = arg.split() for i in args: - bp = bdb.Breakpoint.bpbynumber[int(i)] + try: + i = int(i) + except ValueError: + print 'Breakpoint index %r is not a number' % i + continue + + if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): + print 'No breakpoint numbered', i + continue + + bp = bdb.Breakpoint.bpbynumber[i] if bp: bp.enable() def do_disable(self, arg): args = arg.split() for i in args: - bp = bdb.Breakpoint.bpbynumber[int(i)] + try: + i = int(i) + except ValueError: + print 'Breakpoint index %r is not a number' % i + continue + + if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): + print 'No breakpoint numbered', i + continue + + bp = bdb.Breakpoint.bpbynumber[i] if bp: bp.disable() |