diff --git a/Python/codegen.c b/Python/codegen.c index 766d54d069927ec..d13f8419a61bcd0 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -663,16 +663,8 @@ codegen_enter_scope(compiler *c, identifier name, int scope_type, } static int -codegen_setup_annotations_scope(compiler *c, location loc, - void *key, PyObject *name) +codegen_emit_annotations_prologue(compiler *c, location loc) { - _PyCompile_CodeUnitMetadata umd = { - .u_posonlyargcount = 1, - }; - RETURN_IF_ERROR( - codegen_enter_scope(c, name, COMPILE_SCOPE_ANNOTATIONS, - key, loc.lineno, NULL, &umd)); - // if .format > VALUE_WITH_FAKE_GLOBALS: raise NotImplementedError PyObject *value_with_fake_globals = PyLong_FromLong(_Py_ANNOTATE_FORMAT_VALUE_WITH_FAKE_GLOBALS); assert(!SYMTABLE_ENTRY(c)->ste_has_docstring); @@ -688,6 +680,21 @@ codegen_setup_annotations_scope(compiler *c, location loc, return SUCCESS; } +static int +codegen_setup_annotations_scope(compiler *c, location loc, + void *key, PyObject *name) +{ + _PyCompile_CodeUnitMetadata umd = { + .u_posonlyargcount = 1, + }; + RETURN_IF_ERROR( + codegen_enter_scope(c, name, COMPILE_SCOPE_ANNOTATIONS, + key, loc.lineno, NULL, &umd)); + + RETURN_IF_ERROR_IN_SCOPE(c, codegen_emit_annotations_prologue(c, loc)); + return SUCCESS; +} + static int codegen_leave_annotations_scope(compiler *c, location loc) {