DebugClients/Python/coverage/pytracer.py

changeset 5051
3586ebd9fac8
parent 4489
d0d6e4ad31bd
equal deleted inserted replaced
5047:04e5dfbd3f3d 5051:3586ebd9fac8
90 if tracename not in self.data: 90 if tracename not in self.data:
91 self.data[tracename] = {} 91 self.data[tracename] = {}
92 self.cur_file_dict = self.data[tracename] 92 self.cur_file_dict = self.data[tracename]
93 # The call event is really a "start frame" event, and happens for 93 # The call event is really a "start frame" event, and happens for
94 # function calls and re-entering generators. The f_lasti field is 94 # function calls and re-entering generators. The f_lasti field is
95 # -1 for calls, and a real offset for generators. Use -1 as the 95 # -1 for calls, and a real offset for generators. Use <0 as the
96 # line number for calls, and the real line number for generators. 96 # line number for calls, and the real line number for generators.
97 self.last_line = -1 if (frame.f_lasti < 0) else frame.f_lineno 97 if frame.f_lasti < 0:
98 self.last_line = -frame.f_code.co_firstlineno
99 else:
100 self.last_line = frame.f_lineno
98 elif event == 'line': 101 elif event == 'line':
99 # Record an executed line. 102 # Record an executed line.
100 if self.cur_file_dict is not None: 103 if self.cur_file_dict is not None:
101 lineno = frame.f_lineno 104 lineno = frame.f_lineno
102 if self.trace_arcs: 105 if self.trace_arcs:
132 return self._trace 135 return self._trace
133 136
134 def stop(self): 137 def stop(self):
135 """Stop this Tracer.""" 138 """Stop this Tracer."""
136 self.stopped = True 139 self.stopped = True
137 if self.threading and self.thread != self.threading.currentThread(): 140 if self.threading and self.thread.ident != self.threading.currentThread().ident:
138 # Called on a different thread than started us: we can't unhook 141 # Called on a different thread than started us: we can't unhook
139 # ourselves, but we've set the flag that we should stop, so we 142 # ourselves, but we've set the flag that we should stop, so we
140 # won't do any more tracing. 143 # won't do any more tracing.
141 return 144 return
142 145
148 sys.settrace(None) 151 sys.settrace(None)
149 152
150 def get_stats(self): 153 def get_stats(self):
151 """Return a dictionary of statistics, or None.""" 154 """Return a dictionary of statistics, or None."""
152 return None 155 return None
156
157 #
158 # eflag: FileType = Python2

eric ide

mercurial