Skip to content

Commit 983ae79

Browse files
committed
fix instructions in __annotate__ have incorrect code positions
1 parent ac9d37c commit 983ae79

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Python/codegen.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -685,13 +685,14 @@ codegen_setup_annotations_scope(compiler *c, location loc,
685685
PyObject *value_with_fake_globals = PyLong_FromLong(_Py_ANNOTATE_FORMAT_VALUE_WITH_FAKE_GLOBALS);
686686
assert(!SYMTABLE_ENTRY(c)->ste_has_docstring);
687687
_Py_DECLARE_STR(format, ".format");
688-
ADDOP_I(c, loc, LOAD_FAST, 0);
689-
ADDOP_LOAD_CONST(c, loc, value_with_fake_globals);
690-
ADDOP_I(c, loc, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]);
688+
689+
ADDOP_I(c, NO_LOCATION, LOAD_FAST, 0);
690+
ADDOP_LOAD_CONST(c, NO_LOCATION, value_with_fake_globals);
691+
ADDOP_I(c, NO_LOCATION, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]);
691692
NEW_JUMP_TARGET_LABEL(c, body);
692-
ADDOP_JUMP(c, loc, POP_JUMP_IF_FALSE, body);
693-
ADDOP_I(c, loc, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR);
694-
ADDOP_I(c, loc, RAISE_VARARGS, 1);
693+
ADDOP_JUMP(c, NO_LOCATION, POP_JUMP_IF_FALSE, body);
694+
ADDOP_I(c, NO_LOCATION, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR);
695+
ADDOP_I(c, NO_LOCATION, RAISE_VARARGS, 1);
695696
USE_LABEL(c, body);
696697
return SUCCESS;
697698
}
@@ -750,7 +751,7 @@ codegen_deferred_annotations_body(compiler *c, location loc,
750751
assert(PyList_CheckExact(conditional_annotation_indices));
751752
assert(annotations_len == PyList_Size(conditional_annotation_indices));
752753

753-
ADDOP_I(c, loc, BUILD_MAP, 0); // stack now contains <annos>
754+
ADDOP_I(c, NO_LOCATION, BUILD_MAP, 0); // stack now contains <annos>
754755

755756
for (Py_ssize_t i = 0; i < annotations_len; i++) {
756757
PyObject *ptr = PyList_GET_ITEM(deferred_anno, i);

0 commit comments

Comments
 (0)