diff --git a/Lib/test/test_compiler_assemble.py b/Lib/test/test_compiler_assemble.py index 1b98b0d97..99a11e99d 100644 --- a/Lib/test/test_compiler_assemble.py +++ b/Lib/test/test_compiler_assemble.py @@ -84,7 +84,7 @@ class IsolatedAssembleTests(AssemblerTestCase): return x return inner() % 2 - inner_code = mod_two.__code__.co_consts[1] + inner_code = mod_two.__code__.co_consts[0] assert isinstance(inner_code, types.CodeType) metadata = { @@ -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), @@ -144,4 +146,4 @@ class IsolatedAssembleTests(AssemblerTestCase): L1 to L2 -> L2 [0] L2 to L3 -> L3 [1] lasti """) - self.assertTrue(output.getvalue().endswith(exc_table)) + self.assertEndsWith(output.getvalue(), exc_table) diff --git a/Lib/test/test_compiler_codegen.py b/Lib/test/test_compiler_codegen.py index 8a15c400a..d02937c84 100644 --- a/Lib/test/test_compiler_codegen.py +++ b/Lib/test/test_compiler_codegen.py @@ -26,16 +26,17 @@ class IsolatedCodeGenTests(CodegenTestCase): false_lbl = self.Label() expected = [ ('RESUME', 0, 0), + ('ANNOTATIONS_PLACEHOLDER', None), ('LOAD_CONST', 0, 1), ('TO_BOOL', 0, 1), ('POP_JUMP_IF_FALSE', false_lbl := self.Label(), 1), - ('LOAD_CONST', 1, 1), + ('LOAD_CONST', 1, 1), # 42 ('JUMP_NO_INTERRUPT', exit_lbl := self.Label()), false_lbl, - ('LOAD_CONST', 2, 1), + ('LOAD_CONST', 2, 1), # 24 exit_lbl, ('POP_TOP', None), - ('LOAD_CONST', 3), + ('LOAD_CONST', 1), ('RETURN_VALUE', None), ] self.codegen_test(snippet, expected) @@ -45,6 +46,7 @@ class IsolatedCodeGenTests(CodegenTestCase): false_lbl = self.Label() expected = [ ('RESUME', 0, 0), + ('ANNOTATIONS_PLACEHOLDER', None), ('LOAD_NAME', 0, 1), ('GET_ITER', None, 1), loop_lbl := self.Label(), @@ -59,7 +61,7 @@ class IsolatedCodeGenTests(CodegenTestCase): ('JUMP', loop_lbl), exit_lbl, ('END_FOR', None), - ('POP_TOP', None), + ('POP_ITER', None), ('LOAD_CONST', 0), ('RETURN_VALUE', None), ] @@ -73,6 +75,7 @@ class IsolatedCodeGenTests(CodegenTestCase): expected = [ # Function definition ('RESUME', 0), + ('ANNOTATIONS_PLACEHOLDER', None), ('LOAD_CONST', 0), ('MAKE_FUNCTION', None), ('STORE_NAME', 0), @@ -82,7 +85,7 @@ class IsolatedCodeGenTests(CodegenTestCase): # Function body ('RESUME', 0), ('LOAD_FAST', 0), - ('LOAD_CONST', 1), + ('LOAD_CONST', 42), ('BINARY_OP', 0), ('RETURN_VALUE', None), ('LOAD_CONST', 0), @@ -106,6 +109,7 @@ class IsolatedCodeGenTests(CodegenTestCase): expected = [ # Function definition ('RESUME', 0), + ('ANNOTATIONS_PLACEHOLDER', None), ('LOAD_CONST', 0), ('MAKE_FUNCTION', None), ('STORE_NAME', 0), @@ -125,9 +129,9 @@ class IsolatedCodeGenTests(CodegenTestCase): [ ('RESUME', 0), ('NOP', None), - ('LOAD_CONST', 1), + ('LOAD_CONST', 12), ('RETURN_VALUE', None), - ('LOAD_CONST', 0), + ('LOAD_CONST', 1), ('RETURN_VALUE', None), ], [ @@ -141,7 +145,7 @@ class IsolatedCodeGenTests(CodegenTestCase): ('LOAD_CONST', 4), ('STORE_FAST', 3), ('NOP', None), - ('LOAD_CONST', 5), + ('LOAD_CONST', 42), ('RETURN_VALUE', None), ('LOAD_CONST', 0), ('RETURN_VALUE', None),