summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorgaogaotiantian <gaogaotiantian@hotmail.com>2023-03-27 22:22:06 (GMT)
committerGitHub <noreply@github.com>2023-03-27 22:22:06 (GMT)
commit34eb6f727632d9a1a6998f90c9421e420c785643 (patch)
tree7baf8c3479fd74ec07156577798272f4475b8bd1 /Lib/dis.py
parent36067532467ec58c87ac9c140e555e1866431981 (diff)
downloadcpython-34eb6f727632d9a1a6998f90c9421e420c785643.zip
cpython-34eb6f727632d9a1a6998f90c9421e420c785643.tar.gz
cpython-34eb6f727632d9a1a6998f90c9421e420c785643.tar.bz2
gh-103046: Display current line correctly for `dis.disco()` with CACHE entries (#103047)
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index c3d152b..b39b283 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: