Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ def print_exception_table(self, exception_entries):
target = entry.target_label
print(f" L{start} to L{end} -> L{target} [{entry.depth}]{lasti}", file=file)

def _hasconst_like(op):
return op in hasconst or op == LOAD_SMALL_INT

class ArgResolver:
def __init__(self, co_consts=None, names=None, varname_from_oparg=None, labels_map=None):
Expand Down Expand Up @@ -586,7 +588,7 @@ def get_argval_argrepr(self, op, arg, offset):
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
if _hasconst_like(deop):
argval, argrepr = _get_const_info(deop, arg, self.co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
Expand Down Expand Up @@ -686,7 +688,7 @@ def _get_const_value(op, arg, co_consts):
Otherwise (if it is a LOAD_CONST and co_consts is not
provided) returns the dis.UNKNOWN sentinel.
"""
assert op in hasconst or op == LOAD_SMALL_INT
assert _hasconst_like(op)

if op == LOAD_SMALL_INT:
return arg
Expand Down Expand Up @@ -1009,8 +1011,7 @@ def _find_imports(co):
if op == IMPORT_NAME and i >= 2:
from_op = opargs[i-1]
level_op = opargs[i-2]
if (from_op[0] in hasconst and
(level_op[0] in hasconst or level_op[0] == LOAD_SMALL_INT)):
if from_op[0] in hasconst and _hasconst_like(level_op[0]):
level = _get_const_value(level_op[0], level_op[1], consts)
fromlist = _get_const_value(from_op[0], from_op[1], consts)
yield (names[oparg], level, fromlist)
Expand Down
Loading
Loading