Kaydet (Commit) 9aed6cca authored tarafından Georg Brandl's avatar Georg Brandl

Modernize code in effective().

üst c877a7c2
...@@ -565,47 +565,41 @@ def effective(file, line, frame): ...@@ -565,47 +565,41 @@ def effective(file, line, frame):
that indicates if it is ok to delete a temporary bp. that indicates if it is ok to delete a temporary bp.
""" """
possibles = Breakpoint.bplist[file,line] possibles = Breakpoint.bplist[file, line]
for i in range(0, len(possibles)): for b in possibles:
b = possibles[i] if not b.enabled:
if b.enabled == 0:
continue continue
if not checkfuncname(b, frame): if not checkfuncname(b, frame):
continue continue
# Count every hit when bp is enabled # Count every hit when bp is enabled
b.hits = b.hits + 1 b.hits += 1
if not b.cond: if not b.cond:
# If unconditional, and ignoring, # If unconditional, and ignoring go on to next, else break
# go on to next, else break
if b.ignore > 0: if b.ignore > 0:
b.ignore = b.ignore -1 b.ignore -= 1
continue continue
else: else:
# breakpoint and marker that's ok # breakpoint and marker that it's ok to delete if temporary
# to delete if temporary return (b, True)
return (b,1)
else: else:
# Conditional bp. # Conditional bp.
# Ignore count applies only to those bpt hits where the # Ignore count applies only to those bpt hits where the
# condition evaluates to true. # condition evaluates to true.
try: try:
val = eval(b.cond, frame.f_globals, val = eval(b.cond, frame.f_globals, frame.f_locals)
frame.f_locals)
if val: if val:
if b.ignore > 0: if b.ignore > 0:
b.ignore = b.ignore -1 b.ignore -= 1
# continue # continue
else: else:
return (b,1) return (b, True)
# else: # else:
# continue # continue
except: except:
# if eval fails, most conservative # if eval fails, most conservative thing is to stop on
# thing is to stop on breakpoint # breakpoint regardless of ignore count. Don't delete
# regardless of ignore count. # temporary, as another hint to user.
# Don't delete temporary, return (b, False)
# as another hint to user.
return (b,0)
return (None, None) return (None, None)
# -------------------- testing -------------------- # -------------------- testing --------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment