Skip to content

Commit 0e28896

Browse files
committed
Add helper function to dis.Instruction and use it to reduce churn in test_dis
1 parent 45a24f5 commit 0e28896

File tree

2 files changed

+220
-209
lines changed

2 files changed

+220
-209
lines changed

Lib/dis.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ def show_code(co, *, file=None):
310310
)
311311

312312
_Instruction.opname.__doc__ = "Human readable name for operation"
313-
_Instruction.opcode.__doc__ = "Numeric code for operation"
314313
_Instruction.arg.__doc__ = "Numeric argument to operation (if any), otherwise None"
315314
_Instruction.argval.__doc__ = "Resolved arg value (if known), otherwise same as arg"
316315
_Instruction.argrepr.__doc__ = "Human readable description of operation argument"
@@ -376,6 +375,10 @@ class Instruction(_Instruction):
376375
entries (if any)
377376
"""
378377

378+
@staticmethod
379+
def make(opname, arg, argval, argrepr, offset, start_offset, starts_line, line_number, label=None, positions=None, cache_info=None):
380+
return Instruction(opname, _all_opmap[opname], arg, argval, argrepr, offset, start_offset, starts_line, line_number, label, positions, cache_info)
381+
379382
@property
380383
def oparg(self):
381384
"""Alias for Instruction.arg."""

0 commit comments

Comments
 (0)