eric6/DebugClients/Python/coverage/pytracer.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7975
7d493839a8fc
equal deleted inserted replaced
7991:866adc8c315b 8043:0acf98cd089a
105 self.last_exc_back = None 105 self.last_exc_back = None
106 106
107 if event == 'call': 107 if event == 'call':
108 # Should we start a new context? 108 # Should we start a new context?
109 if self.should_start_context and self.context is None: 109 if self.should_start_context and self.context is None:
110 context_maybe = self.should_start_context(frame) 110 context_maybe = self.should_start_context(frame) # pylint: disable=not-callable
111 if context_maybe is not None: 111 if context_maybe is not None:
112 self.context = context_maybe 112 self.context = context_maybe
113 self.started_context = True 113 self.started_context = True
114 self.switch_context(self.context) 114 self.switch_context(self.context)
115 else: 115 else:
130 ) 130 )
131 filename = frame.f_code.co_filename 131 filename = frame.f_code.co_filename
132 self.cur_file_name = filename 132 self.cur_file_name = filename
133 disp = self.should_trace_cache.get(filename) 133 disp = self.should_trace_cache.get(filename)
134 if disp is None: 134 if disp is None:
135 disp = self.should_trace(filename, frame) 135 disp = self.should_trace(filename, frame) # pylint: disable=not-callable
136 self.should_trace_cache[filename] = disp 136 self.should_trace_cache[filename] = disp # pylint: disable=unsupported-assignment-operation
137 137
138 self.cur_file_dict = None 138 self.cur_file_dict = None
139 if disp.trace: 139 if disp.trace:
140 tracename = disp.source_filename 140 tracename = disp.source_filename
141 if tracename not in self.data: 141 if tracename not in self.data: # pylint: disable=unsupported-membership-test
142 self.data[tracename] = {} 142 self.data[tracename] = {} # pylint: disable=unsupported-assignment-operation
143 self.cur_file_dict = self.data[tracename] 143 self.cur_file_dict = self.data[tracename] # pylint: disable=unsubscriptable-object
144 # The call event is really a "start frame" event, and happens for 144 # The call event is really a "start frame" event, and happens for
145 # function calls and re-entering generators. The f_lasti field is 145 # function calls and re-entering generators. The f_lasti field is
146 # -1 for calls, and a real offset for generators. Use <0 as the 146 # -1 for calls, and a real offset for generators. Use <0 as the
147 # line number for calls, and the real line number for generators. 147 # line number for calls, and the real line number for generators.
148 if getattr(frame, 'f_lasti', -1) < 0: 148 if getattr(frame, 'f_lasti', -1) < 0:
225 # PyPy clears the trace function before running atexit functions, 225 # PyPy clears the trace function before running atexit functions,
226 # so don't warn if we are in atexit on PyPy and the trace function 226 # so don't warn if we are in atexit on PyPy and the trace function
227 # has changed to None. 227 # has changed to None.
228 dont_warn = (env.PYPY and env.PYPYVERSION >= (5, 4) and self.in_atexit and tf is None) 228 dont_warn = (env.PYPY and env.PYPYVERSION >= (5, 4) and self.in_atexit and tf is None)
229 if (not dont_warn) and tf != self._trace: # pylint: disable=comparison-with-callable 229 if (not dont_warn) and tf != self._trace: # pylint: disable=comparison-with-callable
230 self.warn( 230 self.warn( # pylint: disable=not-callable
231 "Trace function changed, measurement is likely wrong: %r" % (tf,), 231 "Trace function changed, measurement is likely wrong: %r" % (tf,),
232 slug="trace-changed", 232 slug="trace-changed",
233 ) 233 )
234 234
235 def activity(self): 235 def activity(self):

eric ide

mercurial