[Python-checkins] python/dist/src/Lib pdb.py,1.64,1.65

akuchling@users.sourceforge.net akuchling@users.sourceforge.net
Thu, 22 May 2003 07:46:14 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv29780

Modified Files:
	pdb.py 
Log Message:
[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.


Index: pdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** pdb.py	9 Apr 2003 19:36:34 -0000	1.64
--- pdb.py	22 May 2003 14:46:12 -0000	1.65
***************
*** 376,380 ****
          args = arg.split()
          for i in args:
!             bp = bdb.Breakpoint.bpbynumber[int(i)]
              if bp:
                  bp.enable()
--- 376,390 ----
          args = arg.split()
          for i in args:
!             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()
***************
*** 383,387 ****
          args = arg.split()
          for i in args:
!             bp = bdb.Breakpoint.bpbynumber[int(i)]
              if bp:
                  bp.disable()
--- 393,407 ----
          args = arg.split()
          for i in args:
!             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()