summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2023-09-13 16:00:15 (GMT)
committerGitHub <noreply@github.com>2023-09-13 16:00:15 (GMT)
commit79101edb03b7381b514126c68acabfcbbba2f842 (patch)
treed32d6fa1b4d763accf7a033ecb065a0f8cc05d04 /Python
parentd69805b38a1815e7aaadf49bdd019c7cca105ac6 (diff)
downloadcpython-79101edb03b7381b514126c68acabfcbbba2f842.zip
cpython-79101edb03b7381b514126c68acabfcbbba2f842.tar.gz
cpython-79101edb03b7381b514126c68acabfcbbba2f842.tar.bz2
gh-109351: Fix crash when compiling AST with invalid NamedExpr (#109352)
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 21cb38f..a230c7e 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -381,6 +381,11 @@ validate_expr(struct validator *state, expr_ty exp, expr_context_ty ctx)
ret = validate_exprs(state, exp->v.Tuple.elts, ctx, 0);
break;
case NamedExpr_kind:
+ if (exp->v.NamedExpr.target->kind != Name_kind) {
+ PyErr_SetString(PyExc_TypeError,
+ "NamedExpr target must be a Name");
+ return 0;
+ }
ret = validate_expr(state, exp->v.NamedExpr.value, Load);
break;
/* This last case doesn't have any checking. */