Python: CG trace: Nicer logging

This commit is contained in:
Rasmus Wriedt Larsen
2020-07-21 21:34:20 +02:00
parent 0a7e6a9938
commit 79c2c682d7
2 changed files with 4 additions and 2 deletions

View File

@@ -176,7 +176,9 @@ def expr_from_instruction(instructions: List[Instruction], index: int) -> Byteco
def expr_from_frame(frame: FrameType) -> BytecodeExpr:
bytecode = dis.Bytecode(frame.f_code, current_offset=frame.f_lasti)
LOGGER.debug(f"bytecode: \n{bytecode.dis()}")
LOGGER.debug(
f"{frame.f_code.co_filename}:{frame.f_lineno}: bytecode: \n{bytecode.dis()}"
)
instructions = list(iter(bytecode))
last_instruction_index = [inst.offset for inst in instructions].index(frame.f_lasti)

View File

@@ -50,7 +50,7 @@ class Call:
del d["bytecode_expr"]
normal_fields = ", ".join(f"{k}={v!r}" for k, v in d.items())
return f"{type(self).__name__}({normal_fields}, bytecode_expr≈{repr(str(self.bytecode_expr))})"
return f"{type(self).__name__}({normal_fields}, bytecode_expr≈{str(self.bytecode_expr)})"
@classmethod
def from_frame(cls, frame: FrameType):