mirror of
https://github.com/python/cpython.git
synced 2025-09-22 08:23:36 +00:00
gh-124019: do not call codegen_annotations_in_scope if there are no annotations (#124020)
This commit is contained in:
parent
a53812df12
commit
6e06e01881
1 changed files with 10 additions and 14 deletions
|
@ -1002,26 +1002,22 @@ codegen_annotations(compiler *c, location loc,
|
||||||
PySTEntryObject *ste;
|
PySTEntryObject *ste;
|
||||||
RETURN_IF_ERROR(_PySymtable_LookupOptional(SYMTABLE(c), args, &ste));
|
RETURN_IF_ERROR(_PySymtable_LookupOptional(SYMTABLE(c), args, &ste));
|
||||||
assert(ste != NULL);
|
assert(ste != NULL);
|
||||||
bool annotations_used = ste->ste_annotations_used;
|
|
||||||
|
|
||||||
int err = annotations_used ?
|
if (ste->ste_annotations_used) {
|
||||||
codegen_setup_annotations_scope(c, loc, (void *)args, ste->ste_name) : SUCCESS;
|
int err = codegen_setup_annotations_scope(c, loc, (void *)args, ste->ste_name);
|
||||||
Py_DECREF(ste);
|
Py_DECREF(ste);
|
||||||
RETURN_IF_ERROR(err);
|
RETURN_IF_ERROR(err);
|
||||||
|
RETURN_IF_ERROR_IN_SCOPE(
|
||||||
if (codegen_annotations_in_scope(c, loc, args, returns, &annotations_len) < 0) {
|
c, codegen_annotations_in_scope(c, loc, args, returns, &annotations_len)
|
||||||
if (annotations_used) {
|
);
|
||||||
_PyCompile_ExitScope(c);
|
|
||||||
}
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (annotations_used) {
|
|
||||||
RETURN_IF_ERROR(
|
RETURN_IF_ERROR(
|
||||||
codegen_leave_annotations_scope(c, loc, annotations_len)
|
codegen_leave_annotations_scope(c, loc, annotations_len)
|
||||||
);
|
);
|
||||||
return MAKE_FUNCTION_ANNOTATE;
|
return MAKE_FUNCTION_ANNOTATE;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Py_DECREF(ste);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue