def __init__(self):
self.breaks = {}
+ # We want to have a method self.canonic() which
+ # canonicalizes filenames before comparing them
+ # but we want the default to be a very fast no-op.
+ # Solution: the built-in str function.
+ if not hasattr(self, "canonic"):
+ self.canonic = str
def reset(self):
import linecache
return 0
def break_here(self, frame):
- filename=frame.f_code.co_filename
+ filename = self.canonic(frame.f_code.co_filename)
if not self.breaks.has_key(filename):
return 0
- lineno=frame.f_lineno
+ lineno = frame.f_lineno
if not lineno in self.breaks[filename]:
return 0
# flag says ok to delete temp. bp
return 0
def break_anywhere(self, frame):
- return self.breaks.has_key(frame.f_code.co_filename)
+ return self.breaks.has_key(
+ self.canonic(frame.f_code.co_filename))
# Derived classes should override the user_* methods
# to gain control.
# for bp in Breakpoint.bpbynumber: if bp: bp.bpprint().
def set_break(self, filename, lineno, temporary=0, cond = None):
+ filename = self.canonic(filename)
import linecache # Import as late as possible
line = linecache.getline(filename, lineno)
if not line:
if not lineno in list:
list.append(lineno)
bp = Breakpoint(filename, lineno, temporary, cond)
+ print "Breakpoint in", filename, "at", lineno
def clear_break(self, filename, lineno):
+ filename = self.canonic(filename)
if not self.breaks.has_key(filename):
return 'There are no breakpoints in %s' % filename
if lineno not in self.breaks[filename]:
self.clear_break(bp.file, bp.line)
def clear_all_file_breaks(self, filename):
+ filename = self.canonic(filename)
if not self.breaks.has_key(filename):
return 'There are no breakpoints in %s' % filename
for line in self.breaks[filename]:
self.breaks = {}
def get_break(self, filename, lineno):
+ filename = self.canonic(filename)
return self.breaks.has_key(filename) and \
lineno in self.breaks[filename]
def get_breaks(self, filename, lineno):
+ filename = self.canonic(filename)
return self.breaks.has_key(filename) and \
lineno in self.breaks[filename] and \
Breakpoint.bplist[filename, lineno] or []
def get_file_breaks(self, filename):
+ filename = self.canonic(filename)
if self.breaks.has_key(filename):
return self.breaks[filename]
else:
def format_stack_entry(self, frame_lineno, lprefix=': '):
import linecache, repr, string
frame, lineno = frame_lineno
- filename = frame.f_code.co_filename
+ filename = self.canonic(frame.f_code.co_filename)
s = filename + '(' + `lineno` + ')'
if frame.f_code.co_name:
s = s + frame.f_code.co_name
# effective break .... see effective()
def __init__(self, file, line, temporary=0, cond = None):
- self.file = file
+ self.file = file # This better be in canonical form!
self.line = line
self.temporary = temporary
self.cond = cond
import linecache, string
name = frame.f_code.co_name
if not name: name = '???'
- fn = frame.f_code.co_filename
+ fn = self.canonic(frame.f_code.co_filename)
line = linecache.getline(fn, frame.f_lineno)
print '+++', fn, frame.f_lineno, name, ':', string.strip(line)
def user_return(self, frame, retval):