Skip to content
Merged
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
3 changes: 3 additions & 0 deletions Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
LOAD_FAST_LOAD_FAST = opmap['LOAD_FAST_LOAD_FAST']
STORE_FAST_LOAD_FAST = opmap['STORE_FAST_LOAD_FAST']
STORE_FAST_STORE_FAST = opmap['STORE_FAST_STORE_FAST']
IS_OP = opmap['IS_OP']

CACHE = opmap["CACHE"]

Expand Down Expand Up @@ -629,6 +630,8 @@ def get_argval_argrepr(self, op, arg, offset):
argrepr = repr(obj)
elif deop == LOAD_SPECIAL:
argrepr = _special_method_names[arg]
elif deop == IS_OP:
argrepr = 'is not' if argval else 'is'
return argval, argrepr

def get_instructions(x, *, first_line=None, show_caches=None, adaptive=False):
Expand Down
9 changes: 9 additions & 0 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,15 @@ def f(x, y, z):
dis.dis(f.__code__, file=output, show_caches=True)
self.assertIn("L1:", output.getvalue())

def test_is_op_format(self):
output = io.StringIO()
dis.dis("a is b", file=output, show_caches=True)
self.assertIn("IS_OP 0 (is)", output.getvalue())

output = io.StringIO()
dis.dis("a is not b", file=output, show_caches=True)
self.assertIn("IS_OP 1 (is not)", output.getvalue())

def test_baseopname_and_baseopcode(self):
# Standard instructions
for name, code in dis.opmap.items():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show string value of :opcode:`IS_OP` oparg in :mod:`dis` output.