summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-10-29 11:15:42 (GMT)
committerGitHub <noreply@github.com>2024-10-29 11:15:42 (GMT)
commitfaa3272fb8d63d481a136cc0467a0cba6ed7b264 (patch)
tree474ac9edbff637a8edb280846a1d3d9b113915c4 /Lib/test
parent67f5c5bd6fcc956a785edef3be67e8cbe470cd31 (diff)
downloadcpython-faa3272fb8d63d481a136cc0467a0cba6ed7b264.zip
cpython-faa3272fb8d63d481a136cc0467a0cba6ed7b264.tar.gz
cpython-faa3272fb8d63d481a136cc0467a0cba6ed7b264.tar.bz2
GH-125837: Split `LOAD_CONST` into three. (GH-125972)
* Add LOAD_CONST_IMMORTAL opcode * Add LOAD_SMALL_INT opcode * Remove RETURN_CONST opcode
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ast/test_ast.py4
-rw-r--r--Lib/test/test_code.py5
-rw-r--r--Lib/test/test_compile.py38
-rw-r--r--Lib/test/test_compiler_assemble.py10
-rw-r--r--Lib/test/test_compiler_codegen.py22
-rw-r--r--Lib/test/test_dis.py323
-rw-r--r--Lib/test/test_embed.py3
-rw-r--r--Lib/test/test_import/__init__.py4
-rw-r--r--Lib/test/test_monitoring.py5
-rw-r--r--Lib/test/test_peepholer.py48
10 files changed, 258 insertions, 204 deletions
diff --git a/Lib/test/test_ast/test_ast.py b/Lib/test/test_ast/test_ast.py
index dd1c644..739a020 100644
--- a/Lib/test/test_ast/test_ast.py
+++ b/Lib/test/test_ast/test_ast.py
@@ -2303,7 +2303,7 @@ class ConstantTests(unittest.TestCase):
co = compile(tree, '<string>', 'exec')
consts = []
for instr in dis.get_instructions(co):
- if instr.opname == 'LOAD_CONST' or instr.opname == 'RETURN_CONST':
+ if instr.opcode in dis.hasconst:
consts.append(instr.argval)
return consts
@@ -2311,7 +2311,7 @@ class ConstantTests(unittest.TestCase):
def test_load_const(self):
consts = [None,
True, False,
- 124,
+ 1000,
2.0,
3j,
"unicode",
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index 93f3a58..dcdd15a 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -254,10 +254,11 @@ class CodeTest(unittest.TestCase):
return x
code = func.__code__
- # different co_name, co_varnames, co_consts
+ # Different co_name, co_varnames, co_consts.
+ # Must have the same number of constants and
+ # variables or we get crashes.
def func2():
y = 2
- z = 3
return y
code2 = func2.__code__
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 6f838da..958170f 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -775,7 +775,6 @@ class TestSpecifics(unittest.TestCase):
self.assertEqual(repr(f1()), repr(const))
check_same_constant(None)
- check_same_constant(0)
check_same_constant(0.0)
check_same_constant(b'abc')
check_same_constant('abc')
@@ -853,9 +852,9 @@ class TestSpecifics(unittest.TestCase):
eval(compile(code, "file.py", "exec"), g)
exec(code, g)
f = g['f']
- expected = tuple([None, '', 1] + [f't{i}' for i in range(N)])
+ expected = tuple([None, ''] + [f't{i}' for i in range(N)])
self.assertEqual(f.__code__.co_consts, expected)
- expected = "".join(expected[3:])
+ expected = "".join(expected[2:])
self.assertEqual(expected, f())
# Stripping unused constants is not a strict requirement for the
@@ -867,7 +866,7 @@ class TestSpecifics(unittest.TestCase):
def f1():
"docstring"
return 42
- self.assertEqual(f1.__code__.co_consts, (f1.__doc__, 42))
+ self.assertEqual(f1.__code__.co_consts, (f1.__doc__,))
# This is a regression test for a CPython specific peephole optimizer
# implementation bug present in a few releases. It's assertion verifies
@@ -884,7 +883,7 @@ class TestSpecifics(unittest.TestCase):
# RETURN_VALUE opcode. This does not always crash an interpreter.
# When you build with the clang memory sanitizer it reliably aborts.
self.assertEqual(
- 'RETURN_CONST',
+ 'RETURN_VALUE',
list(dis.get_instructions(unused_code_at_end))[-1].opname)
@support.cpython_only
@@ -982,7 +981,6 @@ class TestSpecifics(unittest.TestCase):
self.assertEqual(repr(f1()), repr(const1))
self.assertEqual(repr(f2()), repr(const2))
- check_different_constants(0, 0.0)
check_different_constants(+0.0, -0.0)
check_different_constants((0,), (0.0,))
check_different_constants('a', b'a')
@@ -1045,8 +1043,8 @@ class TestSpecifics(unittest.TestCase):
for func in funcs:
opcodes = list(dis.get_instructions(func))
- self.assertLessEqual(len(opcodes), 3)
- self.assertEqual('RETURN_CONST', opcodes[-1].opname)
+ self.assertLessEqual(len(opcodes), 4)
+ self.assertEqual('RETURN_VALUE', opcodes[-1].opname)
self.assertEqual(None, opcodes[-1].argval)
def test_false_while_loop(self):
@@ -1063,8 +1061,8 @@ class TestSpecifics(unittest.TestCase):
# Check that we did not raise but we also don't generate bytecode
for func in funcs:
opcodes = list(dis.get_instructions(func))
- self.assertEqual(2, len(opcodes))
- self.assertEqual('RETURN_CONST', opcodes[1].opname)
+ self.assertEqual(3, len(opcodes))
+ self.assertEqual('RETURN_VALUE', opcodes[-1].opname)
self.assertEqual(None, opcodes[1].argval)
def test_consts_in_conditionals(self):
@@ -1738,7 +1736,7 @@ class TestSourcePositions(unittest.TestCase):
line=1, end_line=3, column=0, end_column=36, occurrence=1)
# The "error msg":
self.assertOpcodeSourcePositionIs(compiled_code, 'LOAD_CONST',
- line=3, end_line=3, column=25, end_column=36, occurrence=4)
+ line=3, end_line=3, column=25, end_column=36, occurrence=2)
self.assertOpcodeSourcePositionIs(compiled_code, 'CALL',
line=1, end_line=3, column=0, end_column=36, occurrence=1)
self.assertOpcodeSourcePositionIs(compiled_code, 'RAISE_VARARGS',
@@ -1760,7 +1758,7 @@ class TestSourcePositions(unittest.TestCase):
line=1, end_line=2, column=1, end_column=8, occurrence=1)
self.assertOpcodeSourcePositionIs(compiled_code, 'JUMP_BACKWARD',
line=1, end_line=2, column=1, end_column=8, occurrence=1)
- self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_CONST',
+ self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_VALUE',
line=4, end_line=4, column=7, end_column=14, occurrence=1)
def test_multiline_async_generator_expression(self):
@@ -1777,7 +1775,7 @@ class TestSourcePositions(unittest.TestCase):
self.assertIsInstance(compiled_code, types.CodeType)
self.assertOpcodeSourcePositionIs(compiled_code, 'YIELD_VALUE',
line=1, end_line=2, column=1, end_column=8, occurrence=2)
- self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_CONST',
+ self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_VALUE',
line=1, end_line=6, column=0, end_column=32, occurrence=1)
def test_multiline_list_comprehension(self):
@@ -1815,7 +1813,7 @@ class TestSourcePositions(unittest.TestCase):
line=2, end_line=3, column=5, end_column=12, occurrence=1)
self.assertOpcodeSourcePositionIs(compiled_code, 'JUMP_BACKWARD',
line=2, end_line=3, column=5, end_column=12, occurrence=1)
- self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_CONST',
+ self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_VALUE',
line=2, end_line=7, column=4, end_column=36, occurrence=1)
def test_multiline_set_comprehension(self):
@@ -1853,7 +1851,7 @@ class TestSourcePositions(unittest.TestCase):
line=2, end_line=3, column=5, end_column=12, occurrence=1)
self.assertOpcodeSourcePositionIs(compiled_code, 'JUMP_BACKWARD',
line=2, end_line=3, column=5, end_column=12, occurrence=1)
- self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_CONST',
+ self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_VALUE',
line=2, end_line=7, column=4, end_column=36, occurrence=1)
def test_multiline_dict_comprehension(self):
@@ -1891,7 +1889,7 @@ class TestSourcePositions(unittest.TestCase):
line=2, end_line=3, column=5, end_column=11, occurrence=1)
self.assertOpcodeSourcePositionIs(compiled_code, 'JUMP_BACKWARD',
line=2, end_line=3, column=5, end_column=11, occurrence=1)
- self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_CONST',
+ self.assertOpcodeSourcePositionIs(compiled_code, 'RETURN_VALUE',
line=2, end_line=7, column=4, end_column=36, occurrence=1)
def test_matchcase_sequence(self):
@@ -2204,8 +2202,8 @@ class TestSourcePositions(unittest.TestCase):
start_line, end_line, _, _ = instr.positions
self.assertEqual(start_line, end_line)
- # Expect three load None instructions for the no-exception __exit__ call,
- # and one RETURN_VALUE.
+ # Expect four `LOAD_CONST None` instructions:
+ # three for the no-exception __exit__ call, and one for the return.
# They should all have the locations of the context manager ('xyz').
load_none = [instr for instr in dis.get_instructions(f) if
@@ -2213,8 +2211,8 @@ class TestSourcePositions(unittest.TestCase):
return_value = [instr for instr in dis.get_instructions(f) if
instr.opname == 'RETURN_VALUE']
- self.assertEqual(len(load_none), 3)
- self.assertEqual(len(return_value), 1)
+ self.assertEqual(len(load_none), 4)
+ self.assertEqual(len(return_value), 2)
for instr in load_none + return_value:
start_line, end_line, start_col, end_col = instr.positions
self.assertEqual(start_line, f.__code__.co_firstlineno + 1)
diff --git a/Lib/test/test_compiler_assemble.py b/Lib/test/test_compiler_assemble.py
index 1b98b0d..625d3c7 100644
--- a/Lib/test/test_compiler_assemble.py
+++ b/Lib/test/test_compiler_assemble.py
@@ -125,13 +125,15 @@ class IsolatedAssembleTests(AssemblerTestCase):
# code for "try: pass\n except: pass"
insts = [
('RESUME', 0),
- ('SETUP_FINALLY', 3),
- ('RETURN_CONST', 0),
- ('SETUP_CLEANUP', 8),
+ ('SETUP_FINALLY', 4),
+ ('LOAD_CONST', 0),
+ ('RETURN_VALUE', None),
+ ('SETUP_CLEANUP', 10),
('PUSH_EXC_INFO', None),
('POP_TOP', None),
('POP_EXCEPT', None),
- ('RETURN_CONST', 0),
+ ('LOAD_CONST', 0),
+ ('RETURN_VALUE', None),
('COPY', 3),
('POP_EXCEPT', None),
('RERAISE', 1),
diff --git a/Lib/test/test_compiler_codegen.py b/Lib/test/test_compiler_codegen.py
index 8a15c40..2dd7cf6 100644
--- a/Lib/test/test_compiler_codegen.py
+++ b/Lib/test/test_compiler_codegen.py
@@ -29,13 +29,13 @@ class IsolatedCodeGenTests(CodegenTestCase):
('LOAD_CONST', 0, 1),
('TO_BOOL', 0, 1),
('POP_JUMP_IF_FALSE', false_lbl := self.Label(), 1),
- ('LOAD_CONST', 1, 1),
+ ('LOAD_SMALL_INT', 42, 1),
('JUMP_NO_INTERRUPT', exit_lbl := self.Label()),
false_lbl,
- ('LOAD_CONST', 2, 1),
+ ('LOAD_SMALL_INT', 24, 1),
exit_lbl,
('POP_TOP', None),
- ('LOAD_CONST', 3),
+ ('LOAD_CONST', 1),
('RETURN_VALUE', None),
]
self.codegen_test(snippet, expected)
@@ -82,7 +82,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
# Function body
('RESUME', 0),
('LOAD_FAST', 0),
- ('LOAD_CONST', 1),
+ ('LOAD_SMALL_INT', 42),
('BINARY_OP', 0),
('RETURN_VALUE', None),
('LOAD_CONST', 0),
@@ -125,23 +125,23 @@ class IsolatedCodeGenTests(CodegenTestCase):
[
('RESUME', 0),
('NOP', None),
- ('LOAD_CONST', 1),
+ ('LOAD_SMALL_INT', 12),
('RETURN_VALUE', None),
- ('LOAD_CONST', 0),
+ ('LOAD_CONST', 1),
('RETURN_VALUE', None),
],
[
('RESUME', 0),
- ('LOAD_CONST', 1),
+ ('LOAD_SMALL_INT', 1),
('STORE_FAST', 0),
- ('LOAD_CONST', 2),
+ ('LOAD_SMALL_INT', 2),
('STORE_FAST', 1),
- ('LOAD_CONST', 3),
+ ('LOAD_SMALL_INT', 3),
('STORE_FAST', 2),
- ('LOAD_CONST', 4),
+ ('LOAD_SMALL_INT', 4),
('STORE_FAST', 3),
('NOP', None),
- ('LOAD_CONST', 5),
+ ('LOAD_SMALL_INT', 42),
('RETURN_VALUE', None),
('LOAD_CONST', 0),
('RETURN_VALUE', None),
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 1f9c04c..bd1d173 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -48,42 +48,46 @@ dis_c_instance_method = """\
%3d RESUME 0
%3d LOAD_FAST 1 (x)
- LOAD_CONST 1 (1)
+ LOAD_SMALL_INT 1
COMPARE_OP 72 (==)
LOAD_FAST 0 (self)
STORE_ATTR 0 (x)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
""" % (_C.__init__.__code__.co_firstlineno, _C.__init__.__code__.co_firstlineno + 1,)
dis_c_instance_method_bytes = """\
RESUME 0
LOAD_FAST 1
- LOAD_CONST 1
+ LOAD_SMALL_INT 1
COMPARE_OP 72 (==)
LOAD_FAST 0
STORE_ATTR 0
- RETURN_CONST 0
+ LOAD_CONST 0
+ RETURN_VALUE
"""
dis_c_class_method = """\
%3d RESUME 0
%3d LOAD_FAST 1 (x)
- LOAD_CONST 1 (1)
+ LOAD_SMALL_INT 1
COMPARE_OP 72 (==)
LOAD_FAST 0 (cls)
STORE_ATTR 0 (x)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
""" % (_C.cm.__code__.co_firstlineno, _C.cm.__code__.co_firstlineno + 2,)
dis_c_static_method = """\
%3d RESUME 0
%3d LOAD_FAST 0 (x)
- LOAD_CONST 1 (1)
+ LOAD_SMALL_INT 1
COMPARE_OP 72 (==)
STORE_FAST 0 (x)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
""" % (_C.sm.__code__.co_firstlineno, _C.sm.__code__.co_firstlineno + 2,)
# Class disassembling info has an extra newline at end.
@@ -110,7 +114,8 @@ dis_f = """\
CALL 1
POP_TOP
-%3d RETURN_CONST 1 (1)
+%3d LOAD_SMALL_INT 1
+ RETURN_VALUE
""" % (_f.__code__.co_firstlineno,
_f.__code__.co_firstlineno + 1,
_f.__code__.co_firstlineno + 2)
@@ -123,7 +128,8 @@ dis_f_with_offsets = """\
14 CALL 1
22 POP_TOP
-%3d 24 RETURN_CONST 1 (1)
+%3d 24 LOAD_SMALL_INT 1
+ 26 RETURN_VALUE
""" % (_f.__code__.co_firstlineno,
_f.__code__.co_firstlineno + 1,
_f.__code__.co_firstlineno + 2)
@@ -136,7 +142,8 @@ dis_f_with_positions_format = f"""\
%-14s CALL 1
%-14s POP_TOP
-%-14s RETURN_CONST 1 (1)
+%-14s LOAD_SMALL_INT 1
+%-14s RETURN_VALUE
"""
dis_f_co_code = """\
@@ -145,7 +152,8 @@ dis_f_co_code = """\
LOAD_FAST 0
CALL 1
POP_TOP
- RETURN_CONST 1
+ LOAD_SMALL_INT 1
+ RETURN_VALUE
"""
def bug708901():
@@ -157,9 +165,9 @@ dis_bug708901 = """\
%3d RESUME 0
%3d LOAD_GLOBAL 1 (range + NULL)
- LOAD_CONST 1 (1)
+ LOAD_SMALL_INT 1
-%3d LOAD_CONST 2 (10)
+%3d LOAD_SMALL_INT 10
%3d CALL 2
GET_ITER
@@ -170,7 +178,8 @@ dis_bug708901 = """\
%3d L2: END_FOR
POP_TOP
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
""" % (bug708901.__code__.co_firstlineno,
bug708901.__code__.co_firstlineno + 1,
bug708901.__code__.co_firstlineno + 2,
@@ -194,7 +203,7 @@ dis_bug1333982 = """\
GET_ITER
CALL 0
-%3d LOAD_CONST 2 (1)
+%3d LOAD_SMALL_INT 1
%3d BINARY_OP 0 (+)
CALL 0
@@ -217,16 +226,17 @@ bug42562.__code__ = bug42562.__code__.replace(co_linetable=b'\xf8')
dis_bug42562 = """\
RESUME 0
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
"""
# Extended arg followed by NOP
code_bug_45757 = bytes([
- opcode.opmap['EXTENDED_ARG'], 0x01, # EXTENDED_ARG 0x01
- opcode.opmap['NOP'], 0xFF, # NOP 0xFF
- opcode.opmap['EXTENDED_ARG'], 0x01, # EXTENDED_ARG 0x01
- opcode.opmap['LOAD_CONST'], 0x29, # LOAD_CONST 0x29
- opcode.opmap['RETURN_VALUE'], 0x00, # RETURN_VALUE 0x00
+ opcode.opmap['EXTENDED_ARG'], 0x01,
+ opcode.opmap['NOP'], 0xFF,
+ opcode.opmap['EXTENDED_ARG'], 0x01,
+ opcode.opmap['LOAD_CONST'], 0x29,
+ opcode.opmap['RETURN_VALUE'], 0x00,
])
dis_bug_45757 = """\
@@ -263,25 +273,27 @@ dis_kw_names = """\
%3d RESUME 0
%3d LOAD_GLOBAL 1 (func_w_kwargs + NULL)
- LOAD_CONST 1 (1)
- LOAD_CONST 2 (2)
- LOAD_CONST 3 (5)
- LOAD_CONST 4 (('c',))
+ LOAD_SMALL_INT 1
+ LOAD_SMALL_INT 2
+ LOAD_SMALL_INT 5
+ LOAD_CONST 1 (('c',))
CALL_KW 3
POP_TOP
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
""" % (wrap_func_w_kwargs.__code__.co_firstlineno,
wrap_func_w_kwargs.__code__.co_firstlineno + 1)
dis_intrinsic_1_2 = """\
0 RESUME 0
- 1 LOAD_CONST 0 (0)
- LOAD_CONST 1 (('*',))
+ 1 LOAD_SMALL_INT 0
+ LOAD_CONST 0 (('*',))
IMPORT_NAME 0 (math)
CALL_INTRINSIC_1 2 (INTRINSIC_IMPORT_STAR)
POP_TOP
- RETURN_CONST 2 (None)
+ LOAD_CONST 1 (None)
+ RETURN_VALUE
"""
dis_intrinsic_1_5 = """\
@@ -307,7 +319,8 @@ _BIG_LINENO_FORMAT = """\
%3d LOAD_GLOBAL 0 (spam)
POP_TOP
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
"""
_BIG_LINENO_FORMAT2 = """\
@@ -315,17 +328,20 @@ _BIG_LINENO_FORMAT2 = """\
%4d LOAD_GLOBAL 0 (spam)
POP_TOP
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
"""
dis_module_expected_results = """\
Disassembly of f:
4 RESUME 0
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
Disassembly of g:
5 RESUME 0
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
"""
@@ -335,7 +351,7 @@ dis_expr_str = """\
0 RESUME 0
1 LOAD_NAME 0 (x)
- LOAD_CONST 0 (1)
+ LOAD_SMALL_INT 1
BINARY_OP 0 (+)
RETURN_VALUE
"""
@@ -346,10 +362,11 @@ dis_simple_stmt_str = """\
0 RESUME 0
1 LOAD_NAME 0 (x)
- LOAD_CONST 0 (1)
+ LOAD_SMALL_INT 1
BINARY_OP 0 (+)
STORE_NAME 0 (x)
- RETURN_CONST 1 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
"""
annot_stmt_str = """\
@@ -363,21 +380,22 @@ lst[fun(0)]: int = 1
dis_annot_stmt_str = """\
0 RESUME 0
- 2 LOAD_CONST 0 (1)
+ 2 LOAD_SMALL_INT 1
STORE_NAME 0 (x)
- 4 LOAD_CONST 0 (1)
+ 4 LOAD_SMALL_INT 1
LOAD_NAME 1 (lst)
LOAD_NAME 2 (fun)
PUSH_NULL
- LOAD_CONST 1 (0)
+ LOAD_SMALL_INT 0
CALL 1
STORE_SUBSCR
- 2 LOAD_CONST 2 (<code object __annotate__ at 0x..., file "<dis>", line 2>)
+ 2 LOAD_CONST 0 (<code object __annotate__ at 0x..., file "<dis>", line 2>)
MAKE_FUNCTION
STORE_NAME 3 (__annotate__)
- RETURN_CONST 3 (None)
+ LOAD_CONST 1 (None)
+ RETURN_VALUE
"""
fn_with_annotate_str = """
@@ -394,7 +412,8 @@ dis_fn_with_annotate_str = """\
MAKE_FUNCTION
SET_FUNCTION_ATTRIBUTE 16 (annotate)
STORE_NAME 0 (foo)
- RETURN_CONST 2 (None)
+ LOAD_CONST 2 (None)
+ RETURN_VALUE
"""
compound_stmt_str = """\
@@ -406,13 +425,13 @@ while 1:
dis_compound_stmt_str = """\
0 RESUME 0
- 1 LOAD_CONST 0 (0)
+ 1 LOAD_SMALL_INT 0
STORE_NAME 0 (x)
2 L1: NOP
3 LOAD_NAME 0 (x)
- LOAD_CONST 1 (1)
+ LOAD_SMALL_INT 1
BINARY_OP 13 (+=)
STORE_NAME 0 (x)
JUMP_BACKWARD 8 (to L1)
@@ -423,8 +442,8 @@ dis_traceback = """\
%4d NOP
-%4d L1: LOAD_CONST 1 (1)
- LOAD_CONST 2 (0)
+%4d L1: LOAD_SMALL_INT 1
+ LOAD_SMALL_INT 0
--> BINARY_OP 11 (/)
POP_TOP
@@ -515,7 +534,7 @@ dis_with = """\
CALL 0
L1: POP_TOP
-%4d LOAD_CONST 1 (1)
+%4d LOAD_SMALL_INT 1
STORE_FAST 1 (x)
%4d L2: LOAD_CONST 0 (None)
@@ -524,9 +543,10 @@ dis_with = """\
CALL 3
POP_TOP
-%4d LOAD_CONST 2 (2)
+%4d LOAD_SMALL_INT 2
STORE_FAST 2 (y)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
%4d L3: PUSH_EXC_INFO
WITH_EXCEPT_START
@@ -539,9 +559,10 @@ dis_with = """\
POP_TOP
POP_TOP
-%4d LOAD_CONST 2 (2)
+%4d LOAD_SMALL_INT 2
STORE_FAST 2 (y)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
-- L6: COPY 3
POP_EXCEPT
@@ -584,7 +605,7 @@ dis_asyncwith = """\
L5: END_SEND
L6: POP_TOP
-%4d LOAD_CONST 1 (1)
+%4d LOAD_SMALL_INT 1
STORE_FAST 1 (x)
%4d L7: LOAD_CONST 0 (None)
@@ -600,14 +621,15 @@ dis_asyncwith = """\
L11: END_SEND
POP_TOP
-%4d LOAD_CONST 2 (2)
+%4d LOAD_SMALL_INT 2
STORE_FAST 2 (y)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
%4d L12: CLEANUP_THROW
- L13: JUMP_BACKWARD_NO_INTERRUPT 25 (to L5)
+ L13: JUMP_BACKWARD_NO_INTERRUPT 26 (to L5)
L14: CLEANUP_THROW
- L15: JUMP_BACKWARD_NO_INTERRUPT 9 (to L11)
+ L15: JUMP_BACKWARD_NO_INTERRUPT 10 (to L11)
L16: PUSH_EXC_INFO
WITH_EXCEPT_START
GET_AWAITABLE 2
@@ -627,9 +649,10 @@ dis_asyncwith = """\
POP_TOP
POP_TOP
-%4d LOAD_CONST 2 (2)
+%4d LOAD_SMALL_INT 2
STORE_FAST 2 (y)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
-- L24: COPY 3
POP_EXCEPT
@@ -716,7 +739,8 @@ dis_tryfinallyconst = """\
PUSH_NULL
CALL 0
POP_TOP
- RETURN_CONST 1 (1)
+ LOAD_SMALL_INT 1
+ RETURN_VALUE
-- L1: PUSH_EXC_INFO
@@ -822,7 +846,8 @@ Disassembly of <code object <genexpr> at 0x..., file "%s", line %d>:
JUMP_BACKWARD 12 (to L2)
L3: END_FOR
POP_TOP
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
-- L4: CALL_INTRINSIC_1 3 (INTRINSIC_STOPITERATION_ERROR)
RERAISE 1
@@ -861,7 +886,7 @@ dis_loop_test_quickened_code = """\
%3d BUILD_LIST 0
LOAD_CONST 1 ((1, 2, 3))
LIST_EXTEND 1
- LOAD_CONST 2 (3)
+ LOAD_SMALL_INT 3
BINARY_OP 5 (*)
GET_ITER
L1: FOR_ITER_LIST 14 (to L2)
@@ -875,7 +900,8 @@ dis_loop_test_quickened_code = """\
%3d L2: END_FOR
POP_TOP
- RETURN_CONST 0 (None)
+ LOAD_CONST_IMMORTAL 0 (None)
+ RETURN_VALUE
""" % (loop_test.__code__.co_firstlineno,
loop_test.__code__.co_firstlineno + 1,
loop_test.__code__.co_firstlineno + 2,
@@ -892,7 +918,8 @@ dis_extended_arg_quick_code = """\
UNPACK_EX 256
POP_TOP
STORE_FAST 0 (_)
- RETURN_CONST 0 (None)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
"""% (extended_arg_quick.__code__.co_firstlineno,
extended_arg_quick.__code__.co_firstlineno + 1,)
@@ -1005,7 +1032,8 @@ class DisTests(DisTestBase):
'',
'2:3-3:15 NOP',
'',
- '3:11-3:15 RETURN_CONST 0 (None)',
+ '3:11-3:15 LOAD_CONST 0 (None)',
+ '3:11-3:15 RETURN_VALUE',
'',
' -- L1: PUSH_EXC_INFO',
'',
@@ -1033,9 +1061,10 @@ class DisTests(DisTestBase):
expect = '\n'.join([
'1:0-1:0 RESUME 0',
'',
- '2:5-2:6 LOAD_CONST 1 (1)',
+ '2:5-2:6 LOAD_SMALL_INT 1',
'2:?-2:? STORE_FAST 0 (x)',
- '2:?-2:? RETURN_CONST 0 (None)',
+ '2:?-2:? LOAD_CONST 0 (None)',
+ '2:?-2:? RETURN_VALUE',
'',
])
self.do_disassembly_test(f, expect, show_positions=True)
@@ -1047,7 +1076,8 @@ class DisTests(DisTestBase):
f.__code__ = f.__code__.replace(co_linetable=b'')
expect = '\n'.join([
' RESUME 0',
- ' RETURN_CONST 0 (None)',
+ ' LOAD_CONST 0 (None)',
+ ' RETURN_VALUE',
'',
])
self.do_disassembly_test(f, expect, show_positions=True)
@@ -1255,7 +1285,7 @@ class DisTests(DisTestBase):
0 RESUME_CHECK 0
1 LOAD_NAME 0 (a)
- LOAD_CONST 0 (0)
+ LOAD_SMALL_INT 0
%s
RETURN_VALUE
"""
@@ -1275,7 +1305,7 @@ class DisTests(DisTestBase):
load_attr_quicken = """\
0 RESUME_CHECK 0
- 1 LOAD_CONST 0 ('a')
+ 1 LOAD_CONST_IMMORTAL 0 ('a')
LOAD_ATTR_SLOT 0 (__class__)
RETURN_VALUE
"""
@@ -1292,7 +1322,7 @@ class DisTests(DisTestBase):
1 LOAD_NAME 0 (str)
PUSH_NULL
- LOAD_CONST 0 (1)
+ LOAD_SMALL_INT 1
CALL_STR_1 1
RETURN_VALUE
"""
@@ -1516,8 +1546,6 @@ Kw-only arguments: 0
Number of locals: 0
Stack size: \\d+
Flags: 0x0
-Constants:
- 0: 1
Names:
0: x"""
@@ -1531,8 +1559,7 @@ Number of locals: 0
Stack size: \\d+
Flags: 0x0
Constants:
- 0: 1
- 1: None
+ 0: None
Names:
0: x"""
@@ -1546,8 +1573,7 @@ Number of locals: 0
Stack size: \\d+
Flags: 0x0
Constants:
- 0: 0
- 1: 1
+ 0: None
Names:
0: x"""
@@ -1568,7 +1594,6 @@ Stack size: \\d+
Flags: OPTIMIZED, NEWLOCALS, COROUTINE
Constants:
0: None
- 1: 1
Names:
0: b
1: c
@@ -1707,10 +1732,10 @@ def _prepare_test_cases():
Instruction = dis.Instruction
expected_opinfo_outer = [
- Instruction(opname='MAKE_CELL', opcode=91, arg=0, argval='a', argrepr='a', offset=0, start_offset=0, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='MAKE_CELL', opcode=91, arg=1, argval='b', argrepr='b', offset=2, start_offset=2, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='MAKE_CELL', opcode=92, arg=0, argval='a', argrepr='a', offset=0, start_offset=0, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='MAKE_CELL', opcode=92, arg=1, argval='b', argrepr='b', offset=2, start_offset=2, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
Instruction(opname='RESUME', opcode=149, arg=0, argval=0, argrepr='', offset=4, start_offset=4, starts_line=True, line_number=1, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=5, argval=(3, 4), argrepr='(3, 4)', offset=6, start_offset=6, starts_line=True, line_number=2, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=4, argval=(3, 4), argrepr='(3, 4)', offset=6, start_offset=6, starts_line=True, line_number=2, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='a', argrepr='a', offset=8, start_offset=8, starts_line=False, line_number=2, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=1, argval='b', argrepr='b', offset=10, start_offset=10, starts_line=False, line_number=2, label=None, positions=None, cache_info=None),
Instruction(opname='BUILD_TUPLE', opcode=48, arg=2, argval=2, argrepr='', offset=12, start_offset=12, starts_line=False, line_number=2, label=None, positions=None, cache_info=None),
@@ -1723,10 +1748,10 @@ expected_opinfo_outer = [
Instruction(opname='LOAD_DEREF', opcode=80, arg=0, argval='a', argrepr='a', offset=34, start_offset=34, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_DEREF', opcode=80, arg=1, argval='b', argrepr='b', offset=36, start_offset=36, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_CONST', opcode=79, arg=2, argval='', argrepr="''", offset=38, start_offset=38, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=3, argval=1, argrepr='1', offset=40, start_offset=40, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=1, argval=1, argrepr='', offset=40, start_offset=40, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
Instruction(opname='BUILD_LIST', opcode=43, arg=0, argval=0, argrepr='', offset=42, start_offset=42, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
Instruction(opname='BUILD_MAP', opcode=44, arg=0, argval=0, argrepr='', offset=44, start_offset=44, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=4, argval='Hello world!', argrepr="'Hello world!'", offset=46, start_offset=46, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=3, argval='Hello world!', argrepr="'Hello world!'", offset=46, start_offset=46, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=7, argval=7, argrepr='', offset=48, start_offset=48, starts_line=False, line_number=7, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=56, start_offset=56, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=2, argval='f', argrepr='f', offset=58, start_offset=58, starts_line=True, line_number=8, label=None, positions=None, cache_info=None),
@@ -1735,8 +1760,8 @@ expected_opinfo_outer = [
expected_opinfo_f = [
Instruction(opname='COPY_FREE_VARS', opcode=58, arg=2, argval=2, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='MAKE_CELL', opcode=91, arg=0, argval='c', argrepr='c', offset=2, start_offset=2, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='MAKE_CELL', opcode=91, arg=1, argval='d', argrepr='d', offset=4, start_offset=4, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='MAKE_CELL', opcode=92, arg=0, argval='c', argrepr='c', offset=2, start_offset=2, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='MAKE_CELL', opcode=92, arg=1, argval='d', argrepr='d', offset=4, start_offset=4, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
Instruction(opname='RESUME', opcode=149, arg=0, argval=0, argrepr='', offset=6, start_offset=6, starts_line=True, line_number=2, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_CONST', opcode=79, arg=2, argval=(5, 6), argrepr='(5, 6)', offset=8, start_offset=8, starts_line=True, line_number=3, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=3, argval='a', argrepr='a', offset=10, start_offset=10, starts_line=False, line_number=3, label=None, positions=None, cache_info=None),
@@ -1771,13 +1796,14 @@ expected_opinfo_inner = [
Instruction(opname='LOAD_FAST_LOAD_FAST', opcode=84, arg=1, argval=('e', 'f'), argrepr='e, f', offset=22, start_offset=22, starts_line=False, line_number=4, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=6, argval=6, argrepr='', offset=24, start_offset=24, starts_line=False, line_number=4, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=32, start_offset=32, starts_line=False, line_number=4, label=None, positions=None, cache_info=None),
- Instruction(opname='RETURN_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=34, start_offset=34, starts_line=False, line_number=4, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=0, argval=None, argrepr='None', offset=34, start_offset=34, starts_line=False, line_number=4, label=None, positions=None, cache_info=None),
+ Instruction(opname='RETURN_VALUE', opcode=33, arg=None, argval=None, argrepr='', offset=36, start_offset=36, starts_line=False, line_number=4, label=None, positions=None, cache_info=None),
]
expected_opinfo_jumpy = [
Instruction(opname='RESUME', opcode=149, arg=0, argval=0, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=1, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_GLOBAL', opcode=87, arg=1, argval='range', argrepr='range + NULL', offset=2, start_offset=2, starts_line=True, line_number=3, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='LOAD_CONST', opcode=79, arg=1, argval=10, argrepr='10', offset=12, start_offset=12, starts_line=False, line_number=3, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=10, argval=10, argrepr='', offset=12, start_offset=12, starts_line=False, line_number=3, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=14, start_offset=14, starts_line=False, line_number=3, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='GET_ITER', opcode=16, arg=None, argval=None, argrepr='', offset=22, start_offset=22, starts_line=False, line_number=3, label=None, positions=None, cache_info=None),
Instruction(opname='FOR_ITER', opcode=67, arg=30, argval=88, argrepr='to L4', offset=24, start_offset=24, starts_line=False, line_number=3, label=1, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
@@ -1787,64 +1813,64 @@ expected_opinfo_jumpy = [
Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=42, start_offset=42, starts_line=False, line_number=4, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=50, start_offset=50, starts_line=False, line_number=4, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='i', argrepr='i', offset=52, start_offset=52, starts_line=True, line_number=5, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=2, argval=4, argrepr='4', offset=54, start_offset=54, starts_line=False, line_number=5, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=4, argval=4, argrepr='', offset=54, start_offset=54, starts_line=False, line_number=5, label=None, positions=None, cache_info=None),
Instruction(opname='COMPARE_OP', opcode=54, arg=18, argval='<', argrepr='bool(<)', offset=56, start_offset=56, starts_line=False, line_number=5, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=94, arg=2, argval=68, argrepr='to L2', offset=60, start_offset=60, starts_line=False, line_number=5, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=95, arg=2, argval=68, argrepr='to L2', offset=60, start_offset=60, starts_line=False, line_number=5, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='JUMP_BACKWARD', opcode=72, arg=22, argval=24, argrepr='to L1', offset=64, start_offset=64, starts_line=True, line_number=6, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='i', argrepr='i', offset=68, start_offset=68, starts_line=True, line_number=7, label=2, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=3, argval=6, argrepr='6', offset=70, start_offset=70, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=6, argval=6, argrepr='', offset=70, start_offset=70, starts_line=False, line_number=7, label=None, positions=None, cache_info=None),
Instruction(opname='COMPARE_OP', opcode=54, arg=148, argval='>', argrepr='bool(>)', offset=72, start_offset=72, starts_line=False, line_number=7, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
- Instruction(opname='POP_JUMP_IF_TRUE', opcode=97, arg=2, argval=84, argrepr='to L3', offset=76, start_offset=76, starts_line=False, line_number=7, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
+ Instruction(opname='POP_JUMP_IF_TRUE', opcode=98, arg=2, argval=84, argrepr='to L3', offset=76, start_offset=76, starts_line=False, line_number=7, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='JUMP_BACKWARD', opcode=72, arg=30, argval=24, argrepr='to L1', offset=80, start_offset=80, starts_line=False, line_number=7, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=84, start_offset=84, starts_line=True, line_number=8, label=3, positions=None, cache_info=None),
Instruction(opname='JUMP_FORWARD', opcode=74, arg=13, argval=114, argrepr='to L5', offset=86, start_offset=86, starts_line=False, line_number=8, label=None, positions=None, cache_info=None),
Instruction(opname='END_FOR', opcode=9, arg=None, argval=None, argrepr='', offset=88, start_offset=88, starts_line=True, line_number=3, label=4, positions=None, cache_info=None),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=90, start_offset=90, starts_line=False, line_number=3, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=92, start_offset=92, starts_line=True, line_number=10, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='LOAD_CONST', opcode=79, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=102, start_offset=102, starts_line=False, line_number=10, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=1, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=102, start_offset=102, starts_line=False, line_number=10, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=104, start_offset=104, starts_line=False, line_number=10, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=112, start_offset=112, starts_line=False, line_number=10, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST_CHECK', opcode=83, arg=0, argval='i', argrepr='i', offset=114, start_offset=114, starts_line=True, line_number=11, label=5, positions=None, cache_info=None),
Instruction(opname='TO_BOOL', opcode=37, arg=None, argval=None, argrepr='', offset=116, start_offset=116, starts_line=False, line_number=11, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('version', 2, b'\x00\x00\x00\x00')]),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=94, arg=33, argval=194, argrepr='to L8', offset=124, start_offset=124, starts_line=False, line_number=11, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=95, arg=33, argval=194, argrepr='to L8', offset=124, start_offset=124, starts_line=False, line_number=11, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=128, start_offset=128, starts_line=True, line_number=12, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='i', argrepr='i', offset=138, start_offset=138, starts_line=False, line_number=12, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=140, start_offset=140, starts_line=False, line_number=12, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=148, start_offset=148, starts_line=False, line_number=12, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='i', argrepr='i', offset=150, start_offset=150, starts_line=True, line_number=13, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=5, argval=1, argrepr='1', offset=152, start_offset=152, starts_line=False, line_number=13, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=1, argval=1, argrepr='', offset=152, start_offset=152, starts_line=False, line_number=13, label=None, positions=None, cache_info=None),
Instruction(opname='BINARY_OP', opcode=42, arg=23, argval=23, argrepr='-=', offset=154, start_offset=154, starts_line=False, line_number=13, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='STORE_FAST', opcode=107, arg=0, argval='i', argrepr='i', offset=158, start_offset=158, starts_line=False, line_number=13, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='i', argrepr='i', offset=160, start_offset=160, starts_line=True, line_number=14, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=3, argval=6, argrepr='6', offset=162, start_offset=162, starts_line=False, line_number=14, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=6, argval=6, argrepr='', offset=162, start_offset=162, starts_line=False, line_number=14, label=None, positions=None, cache_info=None),
Instruction(opname='COMPARE_OP', opcode=54, arg=148, argval='>', argrepr='bool(>)', offset=164, start_offset=164, starts_line=False, line_number=14, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=94, arg=2, argval=176, argrepr='to L6', offset=168, start_offset=168, starts_line=False, line_number=14, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=95, arg=2, argval=176, argrepr='to L6', offset=168, start_offset=168, starts_line=False, line_number=14, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='JUMP_BACKWARD', opcode=72, arg=31, argval=114, argrepr='to L5', offset=172, start_offset=172, starts_line=True, line_number=15, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='i', argrepr='i', offset=176, start_offset=176, starts_line=True, line_number=16, label=6, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=2, argval=4, argrepr='4', offset=178, start_offset=178, starts_line=False, line_number=16, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=4, argval=4, argrepr='', offset=178, start_offset=178, starts_line=False, line_number=16, label=None, positions=None, cache_info=None),
Instruction(opname='COMPARE_OP', opcode=54, arg=18, argval='<', argrepr='bool(<)', offset=180, start_offset=180, starts_line=False, line_number=16, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
- Instruction(opname='POP_JUMP_IF_TRUE', opcode=97, arg=2, argval=192, argrepr='to L7', offset=184, start_offset=184, starts_line=False, line_number=16, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
+ Instruction(opname='POP_JUMP_IF_TRUE', opcode=98, arg=2, argval=192, argrepr='to L7', offset=184, start_offset=184, starts_line=False, line_number=16, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='JUMP_BACKWARD', opcode=72, arg=39, argval=114, argrepr='to L5', offset=188, start_offset=188, starts_line=False, line_number=16, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='JUMP_FORWARD', opcode=74, arg=11, argval=216, argrepr='to L9', offset=192, start_offset=192, starts_line=True, line_number=17, label=7, positions=None, cache_info=None),
Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=194, start_offset=194, starts_line=True, line_number=19, label=8, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='LOAD_CONST', opcode=79, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=204, start_offset=204, starts_line=False, line_number=19, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=2, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=204, start_offset=204, starts_line=False, line_number=19, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=206, start_offset=206, starts_line=False, line_number=19, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=214, start_offset=214, starts_line=False, line_number=19, label=None, positions=None, cache_info=None),
Instruction(opname='NOP', opcode=27, arg=None, argval=None, argrepr='', offset=216, start_offset=216, starts_line=True, line_number=20, label=9, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=5, argval=1, argrepr='1', offset=218, start_offset=218, starts_line=True, line_number=21, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_CONST', opcode=79, arg=7, argval=0, argrepr='0', offset=220, start_offset=220, starts_line=False, line_number=21, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=1, argval=1, argrepr='', offset=218, start_offset=218, starts_line=True, line_number=21, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SMALL_INT', opcode=89, arg=0, argval=0, argrepr='', offset=220, start_offset=220, starts_line=False, line_number=21, label=None, positions=None, cache_info=None),
Instruction(opname='BINARY_OP', opcode=42, arg=11, argval=11, argrepr='/', offset=222, start_offset=222, starts_line=False, line_number=21, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=226, start_offset=226, starts_line=False, line_number=21, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_FAST', opcode=81, arg=0, argval='i', argrepr='i', offset=228, start_offset=228, starts_line=True, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='COPY', opcode=57, arg=1, argval=1, argrepr='', offset=230, start_offset=230, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_SPECIAL', opcode=89, arg=1, argval=1, argrepr='__exit__', offset=232, start_offset=232, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SPECIAL', opcode=90, arg=1, argval=1, argrepr='__exit__', offset=232, start_offset=232, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='SWAP', opcode=112, arg=2, argval=2, argrepr='', offset=234, start_offset=234, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='SWAP', opcode=112, arg=3, argval=3, argrepr='', offset=236, start_offset=236, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_SPECIAL', opcode=89, arg=0, argval=0, argrepr='__enter__', offset=238, start_offset=238, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_SPECIAL', opcode=90, arg=0, argval=0, argrepr='__enter__', offset=238, start_offset=238, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=0, argval=0, argrepr='', offset=240, start_offset=240, starts_line=False, line_number=25, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='STORE_FAST', opcode=107, arg=1, argval='dodgy', argrepr='dodgy', offset=248, start_offset=248, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=250, start_offset=250, starts_line=True, line_number=26, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='LOAD_CONST', opcode=79, arg=8, argval='Never reach this', argrepr="'Never reach this'", offset=260, start_offset=260, starts_line=False, line_number=26, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=3, argval='Never reach this', argrepr="'Never reach this'", offset=260, start_offset=260, starts_line=False, line_number=26, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=262, start_offset=262, starts_line=False, line_number=26, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=270, start_offset=270, starts_line=False, line_number=26, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_CONST', opcode=79, arg=0, argval=None, argrepr='None', offset=272, start_offset=272, starts_line=True, line_number=25, label=None, positions=None, cache_info=None),
@@ -1853,55 +1879,57 @@ expected_opinfo_jumpy = [
Instruction(opname='CALL', opcode=49, arg=3, argval=3, argrepr='', offset=278, start_offset=278, starts_line=False, line_number=25, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=286, start_offset=286, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=288, start_offset=288, starts_line=True, line_number=28, label=10, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='LOAD_CONST', opcode=79, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=298, start_offset=298, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=5, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=298, start_offset=298, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=300, start_offset=300, starts_line=False, line_number=28, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=308, start_offset=308, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
- Instruction(opname='RETURN_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=310, start_offset=310, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
- Instruction(opname='PUSH_EXC_INFO', opcode=30, arg=None, argval=None, argrepr='', offset=312, start_offset=312, starts_line=True, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='WITH_EXCEPT_START', opcode=41, arg=None, argval=None, argrepr='', offset=314, start_offset=314, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='TO_BOOL', opcode=37, arg=None, argval=None, argrepr='', offset=316, start_offset=316, starts_line=False, line_number=25, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('version', 2, b'\x00\x00\x00\x00')]),
- Instruction(opname='POP_JUMP_IF_TRUE', opcode=97, arg=1, argval=330, argrepr='to L11', offset=324, start_offset=324, starts_line=False, line_number=25, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
- Instruction(opname='RERAISE', opcode=99, arg=2, argval=2, argrepr='', offset=328, start_offset=328, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=330, start_offset=330, starts_line=False, line_number=25, label=11, positions=None, cache_info=None),
- Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=332, start_offset=332, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=334, start_offset=334, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=0, argval=None, argrepr='None', offset=310, start_offset=310, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
+ Instruction(opname='RETURN_VALUE', opcode=33, arg=None, argval=None, argrepr='', offset=312, start_offset=312, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
+ Instruction(opname='PUSH_EXC_INFO', opcode=30, arg=None, argval=None, argrepr='', offset=314, start_offset=314, starts_line=True, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='WITH_EXCEPT_START', opcode=41, arg=None, argval=None, argrepr='', offset=316, start_offset=316, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='TO_BOOL', opcode=37, arg=None, argval=None, argrepr='', offset=318, start_offset=318, starts_line=False, line_number=25, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('version', 2, b'\x00\x00\x00\x00')]),
+ Instruction(opname='POP_JUMP_IF_TRUE', opcode=98, arg=1, argval=332, argrepr='to L11', offset=326, start_offset=326, starts_line=False, line_number=25, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
+ Instruction(opname='RERAISE', opcode=100, arg=2, argval=2, argrepr='', offset=330, start_offset=330, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=332, start_offset=332, starts_line=False, line_number=25, label=11, positions=None, cache_info=None),
+ Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=334, start_offset=334, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=336, start_offset=336, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=338, start_offset=338, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='JUMP_BACKWARD_NO_INTERRUPT', opcode=73, arg=27, argval=288, argrepr='to L10', offset=340, start_offset=340, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
- Instruction(opname='COPY', opcode=57, arg=3, argval=3, argrepr='', offset=342, start_offset=342, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=344, start_offset=344, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='RERAISE', opcode=99, arg=1, argval=1, argrepr='', offset=346, start_offset=346, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='PUSH_EXC_INFO', opcode=30, arg=None, argval=None, argrepr='', offset=348, start_offset=348, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_GLOBAL', opcode=87, arg=4, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=350, start_offset=350, starts_line=True, line_number=22, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='CHECK_EXC_MATCH', opcode=5, arg=None, argval=None, argrepr='', offset=360, start_offset=360, starts_line=False, line_number=22, label=None, positions=None, cache_info=None),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=94, arg=14, argval=394, argrepr='to L12', offset=362, start_offset=362, starts_line=False, line_number=22, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
- Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=366, start_offset=366, starts_line=False, line_number=22, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=368, start_offset=368, starts_line=True, line_number=23, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='LOAD_CONST', opcode=79, arg=9, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=378, start_offset=378, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
- Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=380, start_offset=380, starts_line=False, line_number=23, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
- Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=388, start_offset=388, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
- Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=390, start_offset=390, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
- Instruction(opname='JUMP_BACKWARD_NO_INTERRUPT', opcode=73, arg=53, argval=288, argrepr='to L10', offset=392, start_offset=392, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
- Instruction(opname='RERAISE', opcode=99, arg=0, argval=0, argrepr='', offset=394, start_offset=394, starts_line=True, line_number=22, label=12, positions=None, cache_info=None),
- Instruction(opname='COPY', opcode=57, arg=3, argval=3, argrepr='', offset=396, start_offset=396, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=398, start_offset=398, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='RERAISE', opcode=99, arg=1, argval=1, argrepr='', offset=400, start_offset=400, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='PUSH_EXC_INFO', opcode=30, arg=None, argval=None, argrepr='', offset=402, start_offset=402, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=404, start_offset=404, starts_line=True, line_number=28, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
- Instruction(opname='LOAD_CONST', opcode=79, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=414, start_offset=414, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
- Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=416, start_offset=416, starts_line=False, line_number=28, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
- Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=424, start_offset=424, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
- Instruction(opname='RERAISE', opcode=99, arg=0, argval=0, argrepr='', offset=426, start_offset=426, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
- Instruction(opname='COPY', opcode=57, arg=3, argval=3, argrepr='', offset=428, start_offset=428, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=430, start_offset=430, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
- Instruction(opname='RERAISE', opcode=99, arg=1, argval=1, argrepr='', offset=432, start_offset=432, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=340, start_offset=340, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='JUMP_BACKWARD_NO_INTERRUPT', opcode=73, arg=28, argval=288, argrepr='to L10', offset=342, start_offset=342, starts_line=False, line_number=25, label=None, positions=None, cache_info=None),
+ Instruction(opname='COPY', opcode=57, arg=3, argval=3, argrepr='', offset=344, start_offset=344, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=346, start_offset=346, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='RERAISE', opcode=100, arg=1, argval=1, argrepr='', offset=348, start_offset=348, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='PUSH_EXC_INFO', opcode=30, arg=None, argval=None, argrepr='', offset=350, start_offset=350, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_GLOBAL', opcode=87, arg=4, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=352, start_offset=352, starts_line=True, line_number=22, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
+ Instruction(opname='CHECK_EXC_MATCH', opcode=5, arg=None, argval=None, argrepr='', offset=362, start_offset=362, starts_line=False, line_number=22, label=None, positions=None, cache_info=None),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=95, arg=14, argval=396, argrepr='to L12', offset=364, start_offset=364, starts_line=False, line_number=22, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00')]),
+ Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=368, start_offset=368, starts_line=False, line_number=22, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=370, start_offset=370, starts_line=True, line_number=23, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=4, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=380, start_offset=380, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
+ Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=382, start_offset=382, starts_line=False, line_number=23, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
+ Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=390, start_offset=390, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
+ Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=392, start_offset=392, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
+ Instruction(opname='JUMP_BACKWARD_NO_INTERRUPT', opcode=73, arg=54, argval=288, argrepr='to L10', offset=394, start_offset=394, starts_line=False, line_number=23, label=None, positions=None, cache_info=None),
+ Instruction(opname='RERAISE', opcode=100, arg=0, argval=0, argrepr='', offset=396, start_offset=396, starts_line=True, line_number=22, label=12, positions=None, cache_info=None),
+ Instruction(opname='COPY', opcode=57, arg=3, argval=3, argrepr='', offset=398, start_offset=398, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=400, start_offset=400, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='RERAISE', opcode=100, arg=1, argval=1, argrepr='', offset=402, start_offset=402, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='PUSH_EXC_INFO', opcode=30, arg=None, argval=None, argrepr='', offset=404, start_offset=404, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='LOAD_GLOBAL', opcode=87, arg=3, argval='print', argrepr='print + NULL', offset=406, start_offset=406, starts_line=True, line_number=28, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('index', 1, b'\x00\x00'), ('module_keys_version', 1, b'\x00\x00'), ('builtin_keys_version', 1, b'\x00\x00')]),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=5, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=416, start_offset=416, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
+ Instruction(opname='CALL', opcode=49, arg=1, argval=1, argrepr='', offset=418, start_offset=418, starts_line=False, line_number=28, label=None, positions=None, cache_info=[('counter', 1, b'\x00\x00'), ('func_version', 2, b'\x00\x00\x00\x00')]),
+ Instruction(opname='POP_TOP', opcode=29, arg=None, argval=None, argrepr='', offset=426, start_offset=426, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
+ Instruction(opname='RERAISE', opcode=100, arg=0, argval=0, argrepr='', offset=428, start_offset=428, starts_line=False, line_number=28, label=None, positions=None, cache_info=None),
+ Instruction(opname='COPY', opcode=57, arg=3, argval=3, argrepr='', offset=430, start_offset=430, starts_line=True, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='POP_EXCEPT', opcode=28, arg=None, argval=None, argrepr='', offset=432, start_offset=432, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
+ Instruction(opname='RERAISE', opcode=100, arg=1, argval=1, argrepr='', offset=434, start_offset=434, starts_line=False, line_number=None, label=None, positions=None, cache_info=None),
]
# One last piece of inspect fodder to check the default line number handling
def simple(): pass
expected_opinfo_simple = [
Instruction(opname='RESUME', opcode=149, arg=0, argval=0, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=simple.__code__.co_firstlineno, label=None, positions=None),
- Instruction(opname='RETURN_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=2, start_offset=2, starts_line=False, line_number=simple.__code__.co_firstlineno, label=None),
+ Instruction(opname='LOAD_CONST', opcode=79, arg=0, argval=None, argrepr='None', offset=2, start_offset=2, starts_line=False, line_number=simple.__code__.co_firstlineno, label=None),
+ Instruction(opname='RETURN_VALUE', opcode=33, arg=None, argval=None, argrepr='', offset=4, start_offset=4, starts_line=False, line_number=simple.__code__.co_firstlineno, label=None),
]
@@ -1968,6 +1996,7 @@ class InstructionTests(InstructionTestCase):
(2, 2, 8, 9),
(1, 3, 0, 1),
(1, 3, 0, 1),
+ (1, 3, 0, 1),
(1, 3, 0, 1)
]
self.assertEqual(positions, expected)
@@ -2297,20 +2326,20 @@ class BytecodeTests(InstructionTestCase, DisTestBase):
class TestBytecodeTestCase(BytecodeTestCase):
def test_assert_not_in_with_op_not_in_bytecode(self):
code = compile("a = 1", "<string>", "exec")
- self.assertInBytecode(code, "LOAD_CONST", 1)
+ self.assertInBytecode(code, "LOAD_SMALL_INT", 1)
self.assertNotInBytecode(code, "LOAD_NAME")
self.assertNotInBytecode(code, "LOAD_NAME", "a")
def test_assert_not_in_with_arg_not_in_bytecode(self):
code = compile("a = 1", "<string>", "exec")
- self.assertInBytecode(code, "LOAD_CONST")
- self.assertInBytecode(code, "LOAD_CONST", 1)
+ self.assertInBytecode(code, "LOAD_SMALL_INT")
+ self.assertInBytecode(code, "LOAD_SMALL_INT", 1)
self.assertNotInBytecode(code, "LOAD_CONST", 2)
def test_assert_not_in_with_arg_in_bytecode(self):
code = compile("a = 1", "<string>", "exec")
with self.assertRaises(AssertionError):
- self.assertNotInBytecode(code, "LOAD_CONST", 1)
+ self.assertNotInBytecode(code, "LOAD_SMALL_INT", 1)
class TestFinderMethods(unittest.TestCase):
def test__find_imports(self):
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 035d441..4ea43ed 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -388,6 +388,9 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase):
opname in opcode._specialized_opmap
# Exclude superinstructions:
and "__" not in opname
+ # LOAD_CONST_IMMORTAL is "specialized", but is
+ # inserted during quickening.
+ and opname != "LOAD_CONST_IMMORTAL"
):
return True
return False
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index e6fd33e..0e39998 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -1234,7 +1234,7 @@ class PycRewritingTests(unittest.TestCase):
import sys
code_filename = sys._getframe().f_code.co_filename
module_filename = __file__
-constant = 1
+constant = 1000
def func():
pass
func_filename = func.__code__.co_filename
@@ -1303,7 +1303,7 @@ func_filename = func.__code__.co_filename
code = marshal.load(f)
constants = list(code.co_consts)
foreign_code = importlib.import_module.__code__
- pos = constants.index(1)
+ pos = constants.index(1000)
constants[pos] = foreign_code
code = code.replace(co_consts=tuple(constants))
with open(self.compiled_name, "wb") as f:
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py
index 1b06816..b640aa0 100644
--- a/Lib/test/test_monitoring.py
+++ b/Lib/test/test_monitoring.py
@@ -1205,6 +1205,7 @@ class TestLineAndInstructionEvents(CheckEvents):
('instruction', 'func1', 10),
('instruction', 'func1', 12),
('instruction', 'func1', 14),
+ ('instruction', 'func1', 16),
('line', 'get_events', 11)])
def test_c_call(self):
@@ -1229,6 +1230,7 @@ class TestLineAndInstructionEvents(CheckEvents):
('instruction', 'func2', 40),
('instruction', 'func2', 42),
('instruction', 'func2', 44),
+ ('instruction', 'func2', 46),
('line', 'get_events', 11)])
def test_try_except(self):
@@ -1262,6 +1264,7 @@ class TestLineAndInstructionEvents(CheckEvents):
('instruction', 'func3', 30),
('instruction', 'func3', 32),
('instruction', 'func3', 34),
+ ('instruction', 'func3', 36),
('line', 'get_events', 11)])
def test_with_restart(self):
@@ -1282,6 +1285,7 @@ class TestLineAndInstructionEvents(CheckEvents):
('instruction', 'func1', 10),
('instruction', 'func1', 12),
('instruction', 'func1', 14),
+ ('instruction', 'func1', 16),
('line', 'get_events', 11)])
sys.monitoring.restart_events()
@@ -1298,6 +1302,7 @@ class TestLineAndInstructionEvents(CheckEvents):
('instruction', 'func1', 10),
('instruction', 'func1', 12),
('instruction', 'func1', 14),
+ ('instruction', 'func1', 16),
('line', 'get_events', 11)])
def test_turn_off_only_instruction(self):
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index b143f3d..c7da151 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -114,7 +114,7 @@ class TestTranforms(BytecodeTestCase):
return None
self.assertNotInBytecode(f, 'LOAD_GLOBAL')
- self.assertInBytecode(f, 'RETURN_CONST', None)
+ self.assertInBytecode(f, 'LOAD_CONST', None)
self.check_lnotab(f)
def test_while_one(self):
@@ -131,7 +131,7 @@ class TestTranforms(BytecodeTestCase):
def test_pack_unpack(self):
for line, elem in (
- ('a, = a,', 'RETURN_CONST',),
+ ('a, = a,', 'LOAD_CONST',),
('a, b = a, b', 'SWAP',),
('a, b, c = a, b, c', 'SWAP',),
):
@@ -162,7 +162,7 @@ class TestTranforms(BytecodeTestCase):
# One LOAD_CONST for the tuple, one for the None return value
load_consts = [instr for instr in dis.get_instructions(code)
if instr.opname == 'LOAD_CONST']
- self.assertEqual(len(load_consts), 1)
+ self.assertEqual(len(load_consts), 2)
self.check_lnotab(code)
# Bug 1053819: Tuple of constants misidentified when presented with:
@@ -248,14 +248,17 @@ class TestTranforms(BytecodeTestCase):
):
with self.subTest(line=line):
code = compile(line, '', 'single')
- self.assertInBytecode(code, 'LOAD_CONST', elem)
+ if isinstance(elem, int):
+ self.assertInBytecode(code, 'LOAD_SMALL_INT', elem)
+ else:
+ self.assertInBytecode(code, 'LOAD_CONST', elem)
for instr in dis.get_instructions(code):
self.assertFalse(instr.opname.startswith('BINARY_'))
self.check_lnotab(code)
# Verify that unfoldables are skipped
code = compile('a=2+"b"', '', 'single')
- self.assertInBytecode(code, 'LOAD_CONST', 2)
+ self.assertInBytecode(code, 'LOAD_SMALL_INT', 2)
self.assertInBytecode(code, 'LOAD_CONST', 'b')
self.check_lnotab(code)
@@ -307,7 +310,10 @@ class TestTranforms(BytecodeTestCase):
):
with self.subTest(line=line):
code = compile(line, '', 'single')
- self.assertInBytecode(code, 'LOAD_CONST', elem)
+ if isinstance(elem, int):
+ self.assertInBytecode(code, 'LOAD_SMALL_INT', elem)
+ else:
+ self.assertInBytecode(code, 'LOAD_CONST', elem)
for instr in dis.get_instructions(code):
self.assertFalse(instr.opname.startswith('UNARY_'))
self.check_lnotab(code)
@@ -989,9 +995,11 @@ class DirectCfgOptimizerTests(CfgOptimizationTestCase):
expected_insts = [
('LOAD_NAME', 1, 11),
('POP_JUMP_IF_TRUE', lbl := self.Label(), 12),
- ('RETURN_CONST', 1, 13),
+ ('LOAD_CONST', 1, 13),
+ ('RETURN_VALUE', None, 13),
lbl,
- ('RETURN_CONST', 2, 14),
+ ('LOAD_CONST', 2, 14),
+ ('RETURN_VALUE', None, 14),
]
self.cfg_optimization_test(insts,
expected_insts,
@@ -1013,7 +1021,8 @@ class DirectCfgOptimizerTests(CfgOptimizationTestCase):
expected_insts = [
('NOP', None, 11),
('NOP', None, 12),
- ('RETURN_CONST', 1, 14),
+ ('LOAD_CONST', 1, 14),
+ ('RETURN_VALUE', None, 14),
]
self.cfg_optimization_test(insts,
expected_insts,
@@ -1057,15 +1066,19 @@ class DirectCfgOptimizerTests(CfgOptimizationTestCase):
insts = [
('SETUP_FINALLY', handler := self.Label(), 10),
('POP_BLOCK', None, -1),
- ('RETURN_CONST', 1, 11),
+ ('LOAD_CONST', 1, 11),
+ ('RETURN_VALUE', None, 11),
handler,
- ('RETURN_CONST', 2, 12),
+ ('LOAD_CONST', 2, 12),
+ ('RETURN_VALUE', None, 12),
]
expected_insts = [
('SETUP_FINALLY', handler := self.Label(), 10),
- ('RETURN_CONST', 1, 11),
+ ('LOAD_CONST', 1, 11),
+ ('RETURN_VALUE', None, 11),
handler,
- ('RETURN_CONST', 2, 12),
+ ('LOAD_CONST', 2, 12),
+ ('RETURN_VALUE', None, 12),
]
self.cfg_optimization_test(insts, expected_insts, consts=list(range(5)))
@@ -1088,7 +1101,8 @@ class DirectCfgOptimizerTests(CfgOptimizationTestCase):
('NOP', None, 3),
('STORE_FAST', 1, 4),
('POP_TOP', None, 4),
- ('RETURN_CONST', 0)
+ ('LOAD_CONST', 0, 5),
+ ('RETURN_VALUE', None, 5)
]
self.cfg_optimization_test(insts, expected_insts, consts=list(range(3)), nlocals=1)
@@ -1109,7 +1123,8 @@ class DirectCfgOptimizerTests(CfgOptimizationTestCase):
('NOP', None, 3),
('POP_TOP', None, 4),
('STORE_FAST', 1, 4),
- ('RETURN_CONST', 0, 5)
+ ('LOAD_CONST', 0, 5),
+ ('RETURN_VALUE', None, 5)
]
self.cfg_optimization_test(insts, expected_insts, consts=list(range(3)), nlocals=1)
@@ -1131,7 +1146,8 @@ class DirectCfgOptimizerTests(CfgOptimizationTestCase):
('STORE_FAST', 1, 4),
('STORE_FAST', 1, 5),
('STORE_FAST', 1, 6),
- ('RETURN_CONST', 0, 5)
+ ('LOAD_CONST', 0, 5),
+ ('RETURN_VALUE', None, 5)
]
self.cfg_optimization_test(insts, expected_insts, consts=list(range(3)), nlocals=1)