gh-91276: make space for longer opcodes in dis output (GH-91444)

This commit is contained in:
Irit Katriel 2022-04-12 14:35:56 +01:00 committed by GitHub
parent f33e2c87a8
commit e44f988b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 213 additions and 224 deletions

View File

@ -245,7 +245,7 @@ _Instruction.positions.__doc__ = "dis.Positions object holding the span of sourc
_ExceptionTableEntry = collections.namedtuple("_ExceptionTableEntry", _ExceptionTableEntry = collections.namedtuple("_ExceptionTableEntry",
"start end target depth lasti") "start end target depth lasti")
_OPNAME_WIDTH = 20 _OPNAME_WIDTH = max(map(len, opmap))
_OPARG_WIDTH = 5 _OPARG_WIDTH = 5
class Instruction(_Instruction): class Instruction(_Instruction):

View File

@ -683,18 +683,6 @@ class DisTests(DisTestBase):
def test_widths(self): def test_widths(self):
for opcode, opname in enumerate(dis.opname): for opcode, opname in enumerate(dis.opname):
if opname in ('BUILD_MAP_UNPACK_WITH_CALL',
'BUILD_TUPLE_UNPACK_WITH_CALL',
'JUMP_BACKWARD_NO_INTERRUPT',
'POP_JUMP_FORWARD_IF_NONE',
'POP_JUMP_BACKWARD_IF_NONE',
'POP_JUMP_FORWARD_IF_NOT_NONE',
'POP_JUMP_BACKWARD_IF_NOT_NONE',
'POP_JUMP_FORWARD_IF_TRUE',
'POP_JUMP_BACKWARD_IF_TRUE',
'POP_JUMP_FORWARD_IF_FALSE',
'POP_JUMP_BACKWARD_IF_FALSE'):
continue
with self.subTest(opname=opname): with self.subTest(opname=opname):
width = dis._OPNAME_WIDTH width = dis._OPNAME_WIDTH
if opcode < dis.HAVE_ARGUMENT: if opcode < dis.HAVE_ARGUMENT:

View File

@ -0,0 +1 @@
Make space for longer opcodes in :mod:`dis` output.