diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2024-09-12 20:24:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 20:24:15 +0100 |
commit | 6e06e01881dcffbeef5baac0c112ffb14cfa0b27 (patch) | |
tree | 6ef5196c2c59d334a4856a811d9faa420f9bbe03 /Python/codegen.c | |
parent | a53812df126b99bca25187441a123c7785ee82a0 (diff) | |
download | cpython-6e06e01881dcffbeef5baac0c112ffb14cfa0b27.tar.gz cpython-6e06e01881dcffbeef5baac0c112ffb14cfa0b27.zip |
gh-124019: do not call codegen_annotations_in_scope if there are no annotations (#124020)
Diffstat (limited to 'Python/codegen.c')
-rw-r--r-- | Python/codegen.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Python/codegen.c b/Python/codegen.c index 9ce4e1fb1f6..2ca5db1fc6a 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -1002,26 +1002,22 @@ codegen_annotations(compiler *c, location loc, PySTEntryObject *ste; RETURN_IF_ERROR(_PySymtable_LookupOptional(SYMTABLE(c), args, &ste)); assert(ste != NULL); - bool annotations_used = ste->ste_annotations_used; - int err = annotations_used ? - codegen_setup_annotations_scope(c, loc, (void *)args, ste->ste_name) : SUCCESS; - Py_DECREF(ste); - RETURN_IF_ERROR(err); - - if (codegen_annotations_in_scope(c, loc, args, returns, &annotations_len) < 0) { - if (annotations_used) { - _PyCompile_ExitScope(c); - } - return ERROR; - } - - if (annotations_used) { + if (ste->ste_annotations_used) { + int err = codegen_setup_annotations_scope(c, loc, (void *)args, ste->ste_name); + Py_DECREF(ste); + RETURN_IF_ERROR(err); + RETURN_IF_ERROR_IN_SCOPE( + c, codegen_annotations_in_scope(c, loc, args, returns, &annotations_len) + ); RETURN_IF_ERROR( codegen_leave_annotations_scope(c, loc, annotations_len) ); return MAKE_FUNCTION_ANNOTATE; } + else { + Py_DECREF(ste); + } return 0; } |