Skip to content

Commit df7ffdf

Browse files
committed
update test_dis. dis code_info now filters out $ vars
1 parent d2aceb1 commit df7ffdf

File tree

2 files changed

+172
-174
lines changed

2 files changed

+172
-174
lines changed

Lib/dis.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,15 @@ def code_info(x):
198198
return _format_code_info(_get_code_object(x))
199199

200200
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)
201203
lines = []
202204
lines.append("Name: %s" % co.co_name)
203205
lines.append("Filename: %s" % co.co_filename)
204206
lines.append("Argument count: %s" % co.co_argcount)
205207
lines.append("Positional-only arguments: %s" % co.co_posonlyargcount)
206208
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))
208210
lines.append("Stack size: %s" % co.co_stacksize)
209211
lines.append("Flags: %s" % pretty_flags(co.co_flags))
210212
if co.co_consts:
@@ -215,9 +217,9 @@ def _format_code_info(co):
215217
lines.append("Names:")
216218
for i_n in enumerate(co.co_names):
217219
lines.append("%4d: %s" % i_n)
218-
if co.co_varnames:
220+
if realvars:
219221
lines.append("Variable names:")
220-
for i_n in enumerate(co.co_varnames):
222+
for i_n in enumerate(realvars):
221223
lines.append("%4d: %s" % i_n)
222224
if co.co_freevars:
223225
lines.append("Free variables:")

0 commit comments

Comments
 (0)