@@ -335,55 +335,54 @@ def _check_store(variable, instrs):
335335 # Check all watchpoint
336336 hits = False
337337 for bp in Breakpoint .bpbynumber :
338- if not bp :
338+ if not bp or not bp .bptype .endswith ('watchpoint' ):
339+ continue
340+ try :
341+ if frame == bp .var_frame .f_back :
342+ # Variable out of scope
343+ raise ValueError
344+ cur_value = eval (bp .var_name , frame .f_locals )
345+ except (NameError , ValueError ):
346+ self .error ('Watchpoint %d deleted because the program has'
347+ ' left the scope in which its'
348+ ' expression is valid.' % (bp .number )
349+ )
350+ bp .deleteMe ()
339351 continue
340- if bp .bptype .endswith ('watchpoint' ):
341- try :
342- if frame == bp .var_frame .f_back :
343- # Variable out of scope
344- raise ValueError
345- cur_value = eval (bp .var_name , frame .f_locals )
346- except (NameError , ValueError ):
347- self .error ('Watchpoint %d deleted because the program has'
348- ' left the scope in which its'
349- ' expression is valid.' % (bp .number )
350- )
351- bp .deleteMe ()
352- continue
353-
354- hit = False
355- if ((bp .bptype == 'watchpoint' or
356- bp .bptype == 'read/write watchpoint' ) and
357- bp .var_value != cur_value ):
358- # Varialbe value has changed
359- self .message ('\n {}\n \n Old value = {}\n New value = {}' .format (
360- bp ,
361- bp .var_value ,
362- cur_value
363- ))
364-
365- # Update value to latest value
366- bp .var_value = copy .copy (cur_value )
367- hit = True
368- elif (bp .bptype == 'read watchpoint' or
369- bp .bptype == 'read/write watchpoint' ):
370- # Cache file's bytecode instruction by line
371- filename = frame .f_code .co_filename
372- if filename not in self .file_instructions :
373- self .file_instructions [filename ] = _get_line_instructions (frame )
374-
375- # Check bytecode if variable has been read or write
376- # the same value
377- lineno = frame .f_lineno
378- instrs = self .file_instructions [filename ][lineno ]
379- hit = _check_load (bp .var_name , instrs ) or _check_store (bp .var_name , instrs )
380- if hit :
381- self .message ('\n {}\n \n Value = {}' .format (bp , cur_value ))
382352
353+ hit = False
354+ if ((bp .bptype == 'watchpoint' or
355+ bp .bptype == 'read/write watchpoint' ) and
356+ bp .var_value != cur_value ):
357+ # Varialbe value has changed
358+ self .message ('\n {}\n \n Old value = {}\n New value = {}' .format (
359+ bp ,
360+ bp .var_value ,
361+ cur_value
362+ ))
363+
364+ # Update value to latest value
365+ bp .var_value = copy .copy (cur_value )
366+ hit = True
367+ elif (bp .bptype == 'read watchpoint' or
368+ bp .bptype == 'read/write watchpoint' ):
369+ # Cache file's bytecode instruction by line
370+ filename = frame .f_code .co_filename
371+ if filename not in self .file_instructions :
372+ self .file_instructions [filename ] = _get_line_instructions (frame )
373+
374+ # Check bytecode if variable has been read or write
375+ # the same value
376+ lineno = frame .f_lineno
377+ instrs = self .file_instructions [filename ][lineno ]
378+ hit = _check_load (bp .var_name , instrs ) or _check_store (bp .var_name , instrs )
383379 if hit :
384- hits = True
385- bp .hits += 1
386- self .currentbp = bp .number
380+ self .message ('\n {}\n \n Value = {}' .format (bp , cur_value ))
381+
382+ if hit :
383+ hits = True
384+ bp .hits += 1
385+ self .currentbp = bp .number
387386
388387 return hits
389388
0 commit comments