diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/DebugClients/Python/BreakpointWatch.py --- a/src/eric7/DebugClients/Python/BreakpointWatch.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/DebugClients/Python/BreakpointWatch.py Wed Jul 13 14:55:47 2022 +0200 @@ -21,19 +21,20 @@ Breakpoints are indexed by the file,line tuple using breaks. It points to a single Breakpoint instance. This is rather different to the original bdb, since there may be more than one breakpoint per line. - + To test for a specific line in a file there is another dict breakInFile, which is indexed only by filename and holds all line numbers where breakpoints are. """ - breaks = {} # indexed by (filename, lineno) tuple: Breakpoint + + breaks = {} # indexed by (filename, lineno) tuple: Breakpoint breakInFile = {} # indexed by filename: [lineno] breakInFrameCache = {} - + def __init__(self, filename, lineno, temporary=False, cond=None): """ Constructor - + @param filename file name where a breakpoint is set @type str @param lineno line number of the breakpoint @@ -83,7 +84,7 @@ def clear_break(filename, lineno): """ Static method reimplemented from bdb.py to clear a breakpoint. - + @param filename file name of the bp to retrieve @type str @param lineno line number of the bp to retrieve @@ -93,7 +94,7 @@ if bp: bp.deleteMe() Breakpoint.breakInFrameCache.clear() - + @staticmethod def clear_all_breaks(): """ @@ -107,10 +108,10 @@ def get_break(filename, lineno): """ Static method to get the breakpoint of a particular line. - + Because eric supports only one breakpoint per line, this method will return only one breakpoint. - + @param filename file name of the bp to retrieve @type str @param lineno line number of the bp to retrieve @@ -119,7 +120,7 @@ @rtype Breakpoint object or None """ return Breakpoint.breaks.get((filename, lineno)) - + @staticmethod def effectiveBreak(filename, lineno, frame): """ @@ -129,7 +130,7 @@ Called only if we know there is a bpt at this location. Returns breakpoint that was triggered and a flag that indicates if it is ok to delete a temporary bp. - + @param filename file name of the bp to retrieve @type str @param lineno line number of the bp to retrieve @@ -143,7 +144,7 @@ b = Breakpoint.breaks[filename, lineno] if not b.enabled: return (None, False) - + # Count every hit when bp is enabled b.hits += 1 if not b.cond: @@ -161,7 +162,7 @@ # Ignore count applies only to those bpt hits where the # condition evaluates to true. try: - val = eval(b.cond, frame.f_globals, frame.f_locals) # secok + val = eval(b.cond, frame.f_globals, frame.f_locals) # secok if val: if b.ignore > 0: b.ignore -= 1 @@ -185,12 +186,13 @@ Implements temporary watches, ignore counts, disabling and (re)-enabling, and conditionals. """ + watches = [] def __init__(self, cond, compiledCond, flag, temporary=False): """ Constructor - + @param cond condition as string with flag @type str @param compiledCond precompiled condition @@ -203,21 +205,21 @@ # Should not occur if not cond: return - + self.cond = cond self.compiledCond = compiledCond self.temporary = temporary - + self.enabled = True self.ignore = 0 - + self.created = False self.changed = False - if flag == '??created??': + if flag == "??created??": self.created = True - elif flag == '??changed??': + elif flag == "??changed??": self.changed = True - + self.values = {} Watch.watches.append(self) @@ -244,7 +246,7 @@ def clear_watch(cond): """ Static method to clear a watch expression. - + @param cond expression of the watch expression to be cleared @type str """ @@ -262,7 +264,7 @@ def get_watch(cond): """ Static method to get a watch expression. - + @param cond expression of the watch expression to be cleared @type str @return reference to the watch point @@ -271,14 +273,14 @@ for b in Watch.watches: if b.cond == cond: return b - + return None @staticmethod def effectiveWatch(frame): """ Static method to determine, if a watch expression is effective. - + @param frame the current execution frame @type frame object @return tuple of watch expression and a flag to indicate, that a @@ -297,7 +299,7 @@ else: b.values[frame] = [1, val, b.ignore] return (b, True) - + elif b.changed: try: if b.values[frame][1] != val: @@ -306,19 +308,19 @@ continue except KeyError: b.values[frame] = [1, val, b.ignore] - + if b.values[frame][2] > 0: b.values[frame][2] -= 1 continue else: return (b, True) - + elif val: if b.ignore > 0: b.ignore -= 1 continue else: return (b, True) - except Exception: # secok + except Exception: # secok continue return (None, False)