Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ def print_instruction(self, instr, mark_as_current=False):
# Only show the fancy argrepr for a CACHE instruction when it's
# the first entry for a particular cache value:
if i == 0:
argrepr = f"{name}: {int.from_bytes(data, sys.byteorder)}"
data_int = int.from_bytes(data, sys.byteorder)
argrepr = f"{name}: {data_int}"
if name == "counter":
argrepr += f" (value: {data_int >> 4}, backoff: {data_int & 15})"
Comment on lines +463 to +466
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be extracted into a helper function in case we want to add more information later.

else:
argrepr = ""
self.print_instruction_line(
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@ def test_show_cache(self):
1 LOAD_NAME 0 (print)
PUSH_NULL
CALL 0
CACHE 0 (counter: 0)
CACHE 0 (counter: 0 (value: 0, backoff: 0))
CACHE 0 (func_version: 0)
CACHE 0
POP_TOP
Expand Down
Loading