New submission from Thomas Grainger <tagr...@gmail.com>:
the following code prints: import sys import dis import pprint def demo(): for i in range(1): if i >= 0: pass class Tracer: def __init__(self): self.events = [] def trace(self, frame, event, arg): self.events.append((frame.f_lineno, frame.f_lasti, event)) frame.f_trace_lines = True frame.f_trace_opcodes = True return self.trace def main(): t = Tracer() old_trace = sys.gettrace() try: sys.settrace(t.trace) demo() finally: sys.settrace(old_trace) dis.dis(demo) pprint.pp(t.events) if __name__ == "__main__": sys.exit(main()) 7 0 LOAD_GLOBAL 0 (range) 2 LOAD_CONST 1 (1) 4 CALL_FUNCTION 1 6 GET_ITER >> 8 FOR_ITER 7 (to 24) 10 STORE_FAST 0 (i) 8 12 LOAD_FAST 0 (i) 14 LOAD_CONST 2 (0) 16 COMPARE_OP 5 (>=) 18 POP_JUMP_IF_FALSE 11 (to 22) 9 20 NOP >> 22 JUMP_ABSOLUTE 4 (to 8) 7 >> 24 LOAD_CONST 0 (None) 26 RETURN_VALUE [(6, -1, 'call'), (7, 0, 'line'), (7, 0, 'opcode'), (7, 2, 'opcode'), (7, 4, 'opcode'), (7, 6, 'opcode'), (7, 8, 'opcode'), (7, 10, 'opcode'), (8, 12, 'line'), (8, 12, 'opcode'), (8, 14, 'opcode'), (8, 16, 'opcode'), (8, 18, 'opcode'), (9, 20, 'line'), (9, 20, 'opcode'), (None, 22, 'opcode'), (7, 8, 'line'), (7, 8, 'opcode'), (7, 24, 'opcode'), (7, 26, 'opcode'), (7, 26, 'return')] but I'd expect (9, 22, 'opcode') instead of (None, 22, 'opcode'), ---------- messages: 415697 nosy: graingert priority: normal severity: normal status: open title: missing frame.f_lineno on JUMP_ABSOLUTE versions: Python 3.10, Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47085> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com