gh-112962: in dis module, put cache information in the Instruction instead of creating fake Instructions to represent it (#113016)

This commit is contained in:
Irit Katriel 2023-12-13 12:00:21 +00:00 committed by GitHub
parent 3531ea441b
commit 428c9812cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 115 additions and 47 deletions

View file

@ -144,6 +144,8 @@ from test.support import (cpython_only,
gc_collect)
from test.support.script_helper import assert_python_ok
from test.support import threading_helper
from test.support.bytecode_helper import (BytecodeTestCase,
instructions_with_positions)
from opcode import opmap, opname
COPY_FREE_VARS = opmap['COPY_FREE_VARS']
@ -384,10 +386,8 @@ class CodeTest(unittest.TestCase):
code = traceback.tb_frame.f_code
artificial_instructions = []
for instr, positions in zip(
dis.get_instructions(code, show_caches=True),
code.co_positions(),
strict=True
for instr, positions in instructions_with_positions(
dis.get_instructions(code), code.co_positions()
):
# If any of the positions is None, then all have to
# be None as well for the case above. There are still