Skip to content

Commit 4b2ec1e

Browse files
committed
fix instructions in __annotate__ have incorrect code positions
1 parent 3343fce commit 4b2ec1e

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
@@ -686,13 +686,14 @@ codegen_setup_annotations_scope(compiler *c, location loc,
686686
PyObject *value_with_fake_globals = PyLong_FromLong(_Py_ANNOTATE_FORMAT_VALUE_WITH_FAKE_GLOBALS);
687687
assert(!SYMTABLE_ENTRY(c)->ste_has_docstring);
688688
_Py_DECLARE_STR(format, ".format");
689-
ADDOP_I(c, loc, LOAD_FAST, 0);
690-
ADDOP_LOAD_CONST(c, loc, value_with_fake_globals);
691-
ADDOP_I(c, loc, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]);
689+
690+
ADDOP_I(c, NO_LOCATION, LOAD_FAST, 0);
691+
ADDOP_LOAD_CONST(c, NO_LOCATION, value_with_fake_globals);
692+
ADDOP_I(c, NO_LOCATION, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]);
692693
NEW_JUMP_TARGET_LABEL(c, body);
693-
ADDOP_JUMP(c, loc, POP_JUMP_IF_FALSE, body);
694-
ADDOP_I(c, loc, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR);
695-
ADDOP_I(c, loc, RAISE_VARARGS, 1);
694+
ADDOP_JUMP(c, NO_LOCATION, POP_JUMP_IF_FALSE, body);
695+
ADDOP_I(c, NO_LOCATION, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR);
696+
ADDOP_I(c, NO_LOCATION, RAISE_VARARGS, 1);
696697
USE_LABEL(c, body);
697698
return SUCCESS;
698699
}
@@ -751,7 +752,7 @@ codegen_deferred_annotations_body(compiler *c, location loc,
751752
assert(PyList_CheckExact(conditional_annotation_indices));
752753
assert(annotations_len == PyList_Size(conditional_annotation_indices));
753754

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

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

0 commit comments

Comments
 (0)