summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-02 14:58:06 (GMT)
committerGitHub <noreply@github.com>2023-10-02 14:58:06 (GMT)
commit4b2ba3d0b8a1b2a722aeeefc01fd3162f46d95fc (patch)
tree5bd8b4c5438be1d684a2eb8e6fae94cab158fb4b /Python
parent2fb39f73ed0b96c0097106226d44f27472be630c (diff)
downloadcpython-4b2ba3d0b8a1b2a722aeeefc01fd3162f46d95fc.zip
cpython-4b2ba3d0b8a1b2a722aeeefc01fd3162f46d95fc.tar.gz
cpython-4b2ba3d0b8a1b2a722aeeefc01fd3162f46d95fc.tar.bz2
[3.12] gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352) (#109379)
gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352) (cherry picked from commit 79101edb03b7381b514126c68acabfcbbba2f842) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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 a3acf78..82d7bee 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. */