https://github.com/python/cpython/commit/04c7f362055477efeaf3d539da30a608cdbbdc1e
commit: 04c7f362055477efeaf3d539da30a608cdbbdc1e
branch: main
author: Dino Viehland <[email protected]>
committer: DinoV <[email protected]>
date: 2025-09-09T18:17:00-07:00
summary:

gh-138230: Remove dead code in code gen - codegen_check_annotation is only 
calle… (#138228)

Remove dead code in code gen - codegen_check_annotation is only called if 
future annotations are enabled, and if future annotations are enabled it does 
nothing.

files:
M Python/codegen.c

diff --git a/Python/codegen.c b/Python/codegen.c
index b0778518b2eeb2..ed172dbc0e292e 100644
--- a/Python/codegen.c
+++ b/Python/codegen.c
@@ -5414,23 +5414,6 @@ codegen_check_ann_expr(compiler *c, expr_ty e)
     return SUCCESS;
 }
 
-static int
-codegen_check_annotation(compiler *c, stmt_ty s)
-{
-    /* Annotations of complex targets does not produce anything
-       under annotations future */
-    if (FUTURE_FEATURES(c) & CO_FUTURE_ANNOTATIONS) {
-        return SUCCESS;
-    }
-
-    /* Annotations are only evaluated in a module or class. */
-    if (SCOPE_TYPE(c) == COMPILE_SCOPE_MODULE ||
-        SCOPE_TYPE(c) == COMPILE_SCOPE_CLASS) {
-        return codegen_check_ann_expr(c, s->v.AnnAssign.annotation);
-    }
-    return SUCCESS;
-}
-
 static int
 codegen_check_ann_subscr(compiler *c, expr_ty e)
 {
@@ -5524,10 +5507,6 @@ codegen_annassign(compiler *c, stmt_ty s)
                      targ->kind);
         return ERROR;
     }
-    /* Annotation is evaluated last. */
-    if (future_annotations && !s->v.AnnAssign.simple && 
codegen_check_annotation(c, s) < 0) {
-        return ERROR;
-    }
     return SUCCESS;
 }
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to