From 34eb6f727632d9a1a6998f90c9421e420c785643 Mon Sep 17 00:00:00 2001 From: gaogaotiantian Date: Mon, 27 Mar 2023 15:22:06 -0700 Subject: gh-103046: Display current line correctly for `dis.disco()` with CACHE entries (#103047) --- Lib/dis.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Lib/dis.py') diff --git a/Lib/dis.py b/Lib/dis.py index c3d152b4de0..b39b2835330 100644 --- a/Lib/dis.py +++ b/Lib/dis.py @@ -581,7 +581,12 @@ def _disassemble_bytes(code, lasti=-1, varname_from_oparg=None, instr.offset > 0) if new_source_line: print(file=file) - is_current_instr = instr.offset == lasti + if show_caches: + is_current_instr = instr.offset == lasti + else: + # Each CACHE takes 2 bytes + is_current_instr = instr.offset <= lasti \ + <= instr.offset + 2 * _inline_cache_entries[_deoptop(instr.opcode)] print(instr._disassemble(lineno_width, is_current_instr, offset_width), file=file) if exception_entries: -- cgit v1.2.3