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

Skip to content

Commit 3539798

Browse files
committed
Python: CG trace: ignore with statement for now
1 parent 4843d29 commit 3539798

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ 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+
# TODO: handle with statements (https://docs.python.org/3/library/dis.html#opcode-SETUP_WITH)
184+
WITH_OPNAMES = ["SETUP_WITH", "WITH_CLEANUP_START", "WITH_CLEANUP_FINISH"]
185+
183186
# Special cases ignored for now:
184187
#
185188
# - LOAD_BUILD_CLASS: Called when constructing a class.
186189
# - IMPORT_NAME: Observed to result in a call to filename='<frozen
187190
# importlib._bootstrap>', linenum=389, funcname='parent'
188-
if inst.opname not in ["LOAD_BUILD_CLASS", "IMPORT_NAME"]:
191+
if inst.opname not in ["LOAD_BUILD_CLASS", "IMPORT_NAME"] + WITH_OPNAMES:
189192
LOGGER.warning(f"Don't know how to handle this type of instruction: {inst}")
190193
# Uncomment to stop execution when encountering non-ignored unknown instruction
191194
# class MyBytecodeException(BaseException):

0 commit comments

Comments
 (0)