@@ -34,6 +34,8 @@ def __init__(self, skip=None):
3434 self .fncache = {}
3535 self .frame_returning = None
3636
37+ self ._load_breaks ()
38+
3739 def canonic (self , filename ):
3840 """Return canonical form of filename.
3941
@@ -117,7 +119,7 @@ def dispatch_call(self, frame, arg):
117119 """Invoke user function and return trace function for call event.
118120
119121 If the debugger stops on this function call, invoke
120- self.user_call(). Raise BbdQuit if self.quitting is set.
122+ self.user_call(). Raise BdbQuit if self.quitting is set.
121123 Return self.trace_dispatch to continue tracing in this scope.
122124 """
123125 # XXX 'arg' is no longer used
@@ -365,6 +367,12 @@ def set_quit(self):
365367 # Call self.get_*break*() to see the breakpoints or better
366368 # for bp in Breakpoint.bpbynumber: if bp: bp.bpprint().
367369
370+ def _add_to_breaks (self , filename , lineno ):
371+ """Add breakpoint to breaks, if not already there."""
372+ bp_linenos = self .breaks .setdefault (filename , [])
373+ if lineno not in bp_linenos :
374+ bp_linenos .append (lineno )
375+
368376 def set_break (self , filename , lineno , temporary = False , cond = None ,
369377 funcname = None ):
370378 """Set a new breakpoint for filename:lineno.
@@ -377,12 +385,21 @@ def set_break(self, filename, lineno, temporary=False, cond=None,
377385 line = linecache .getline (filename , lineno )
378386 if not line :
379387 return 'Line %s:%d does not exist' % (filename , lineno )
380- list = self .breaks .setdefault (filename , [])
381- if lineno not in list :
382- list .append (lineno )
388+ self ._add_to_breaks (filename , lineno )
383389 bp = Breakpoint (filename , lineno , temporary , cond , funcname )
384390 return None
385391
392+ def _load_breaks (self ):
393+ """Apply all breakpoints (set in other instances) to this one.
394+
395+ Populates this instance's breaks list from the Breakpoint class's
396+ list, which can have breakpoints set by another Bdb instance. This
397+ is necessary for interactive sessions to keep the breakpoints
398+ active across multiple calls to run().
399+ """
400+ for (filename , lineno ) in Breakpoint .bplist .keys ():
401+ self ._add_to_breaks (filename , lineno )
402+
386403 def _prune_breaks (self , filename , lineno ):
387404 """Prune breakpoints for filename:lineno.
388405
@@ -611,26 +628,11 @@ def runctx(self, cmd, globals, locals):
611628
612629 # This method is more useful to debug a single function call.
613630
614- def runcall (* args , ** kwds ):
631+ def runcall (self , func , / , * args , ** kwds ):
615632 """Debug a single function call.
616633
617634 Return the result of the function call.
618635 """
619- if len (args ) >= 2 :
620- self , func , * args = args
621- elif not args :
622- raise TypeError ("descriptor 'runcall' of 'Bdb' object "
623- "needs an argument" )
624- elif 'func' in kwds :
625- func = kwds .pop ('func' )
626- self , * args = args
627- import warnings
628- warnings .warn ("Passing 'func' as keyword argument is deprecated" ,
629- DeprecationWarning , stacklevel = 2 )
630- else :
631- raise TypeError ('runcall expected at least 1 positional argument, '
632- 'got %d' % (len (args )- 1 ))
633-
634636 self .reset ()
635637 sys .settrace (self .trace_dispatch )
636638 res = None
@@ -642,7 +644,6 @@ def runcall(*args, **kwds):
642644 self .quitting = True
643645 sys .settrace (None )
644646 return res
645- runcall .__text_signature__ = '($self, func, /, *args, **kwds)'
646647
647648
648649def set_trace ():
@@ -697,6 +698,12 @@ def __init__(self, file, line, temporary=False, cond=None, funcname=None):
697698 else :
698699 self .bplist [file , line ] = [self ]
699700
701+ @staticmethod
702+ def clearBreakpoints ():
703+ Breakpoint .next = 1
704+ Breakpoint .bplist = {}
705+ Breakpoint .bpbynumber = [None ]
706+
700707 def deleteMe (self ):
701708 """Delete the breakpoint from the list associated to a file:line.
702709
0 commit comments