@@ -154,6 +154,17 @@ def _min_depths(self):
154
154
def level (self ):
155
155
return len (self .tracedframes )
156
156
157
+ def _method_or_function_call (self , frame , ident ):
158
+ f = self .functions [ident ]
159
+ args = inspect .getargvalues (frame )
160
+ if inspect .ismethod (f ):
161
+ locs = args .locals .copy ()
162
+ f_self = locs .pop (args .args [0 ])
163
+ self .trace_in ("%s.%s" % (repr (f_self ), f .__name__ ), [], locs )
164
+ else :
165
+ # regular function
166
+ self .trace_in (_name (f ), [], args .locals )
167
+
157
168
def tracefunc (self , frame , event , arg ):
158
169
try :
159
170
if event == 'call' :
@@ -168,10 +179,7 @@ def tracefunc(self, frame, event, arg):
168
179
min_depth_limit = next_depth_limit
169
180
170
181
if self .level < min_depth_limit :
171
- args = inspect .getargvalues (frame )
172
- self .trace_in (_name (self .functions [ident ]),
173
- [],
174
- args .locals )
182
+ self ._method_or_function_call (frame , ident )
175
183
if self .level <= min_depth_limit :
176
184
self .tracedframes .append ((frame .f_back , min_depth_limit , self .level < min_depth_limit ))
177
185
@@ -198,7 +206,8 @@ def tracefunc(self, frame, event, arg):
198
206
self .trace_out (arg [0 ], exception = True )
199
207
self .tracedframes .pop ()
200
208
except :
201
- pass # just swallow errors to avoid interference with traced processes
209
+ pass # just swallow errors to avoid interference with traced processes
210
+ # raise # for debugging
202
211
return self .tracefunc
203
212
204
213
def close (self ):
0 commit comments