summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-09-13 16:32:08 (GMT)
committerGitHub <noreply@github.com>2023-09-13 16:32:08 (GMT)
commitf1f85a42eafd31720cf905c5407ca3e043946698 (patch)
treea33733ab05a9cf8d5605db2c09409eb3704b4c44 /Python
parent66c0d0ac8c55be9c973be1189b0e9ffcfdfb35a4 (diff)
downloadcpython-f1f85a42eafd31720cf905c5407ca3e043946698.zip
cpython-f1f85a42eafd31720cf905c5407ca3e043946698.tar.gz
cpython-f1f85a42eafd31720cf905c5407ca3e043946698.tar.bz2
[3.11] gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352) (#109380)
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 95179cb..8bc3c96 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -379,6 +379,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. */