File tree 2 files changed +172
-174
lines changed
2 files changed +172
-174
lines changed Original file line number Diff line number Diff line change @@ -198,13 +198,15 @@ def code_info(x):
198
198
return _format_code_info (_get_code_object (x ))
199
199
200
200
def _format_code_info (co ):
201
+ realvars = tuple (n for n in co .co_varnames if not n .startswith ('$' ))
202
+ ntmpvars = len (co .co_varnames ) - len (realvars )
201
203
lines = []
202
204
lines .append ("Name: %s" % co .co_name )
203
205
lines .append ("Filename: %s" % co .co_filename )
204
206
lines .append ("Argument count: %s" % co .co_argcount )
205
207
lines .append ("Positional-only arguments: %s" % co .co_posonlyargcount )
206
208
lines .append ("Kw-only arguments: %s" % co .co_kwonlyargcount )
207
- lines .append ("Number of locals: %s" % co .co_nlocals )
209
+ lines .append ("Number of locals: %s" % ( co .co_nlocals - ntmpvars ) )
208
210
lines .append ("Stack size: %s" % co .co_stacksize )
209
211
lines .append ("Flags: %s" % pretty_flags (co .co_flags ))
210
212
if co .co_consts :
@@ -215,9 +217,9 @@ def _format_code_info(co):
215
217
lines .append ("Names:" )
216
218
for i_n in enumerate (co .co_names ):
217
219
lines .append ("%4d: %s" % i_n )
218
- if co . co_varnames :
220
+ if realvars :
219
221
lines .append ("Variable names:" )
220
- for i_n in enumerate (co . co_varnames ):
222
+ for i_n in enumerate (realvars ):
221
223
lines .append ("%4d: %s" % i_n )
222
224
if co .co_freevars :
223
225
lines .append ("Free variables:" )
You can’t perform that action at this time.
0 commit comments