Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebbea0c

Browse files
committed
Python: CG trace: Ignore IMPORT_NAME
1 parent 6830804 commit ebbea0c

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

python/tools/recorded-call-graph-metrics/src/cg_trace/bytecode_reconstructor.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,18 @@ def expr_from_instruction(instructions: List[Instruction], index: int) -> Byteco
180180
assert isinstance(name_expr, BytecodeConst)
181181
return BytecodeMakeFunction(qualified_name=name_expr)
182182

183-
# LOAD_BUILD_CLASS is included here intentionally for now, since I don't really
184-
# know what to do about it.
185-
if inst.opname not in ["LOAD_BUILD_CLASS"]:
183+
# Special cases ignored for now:
184+
#
185+
# - LOAD_BUILD_CLASS: Called when constructing a class.
186+
# - IMPORT_NAME: Observed to result in a call to filename='<frozen
187+
# importlib._bootstrap>', linenum=389, funcname='parent'
188+
if inst.opname not in ["LOAD_BUILD_CLASS", "IMPORT_NAME"]:
186189
LOGGER.warning(f"Don't know how to handle this type of instruction: {inst}")
190+
# Uncomment to stop execution when encountering non-ignored unknown instruction
191+
# class MyBytecodeException(BaseException):
192+
# pass
193+
#
194+
# raise MyBytecodeException()
187195
return BytecodeUnknown(inst.opname)
188196

189197

0 commit comments

Comments
 (0)