Skip to content

Commit

Permalink
TypeError is more consistent with AnnAssign
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Sep 12, 2023
1 parent c8d43ca commit cd999bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def test_compile_invalid_namedexpr(self):
type_ignores=[],
)

with self.assertRaisesRegex(ValueError, "NamedExpr target must be a Name"):
with self.assertRaisesRegex(TypeError, "NamedExpr target must be a Name"):
compile(ast.fix_missing_locations(m), "<file>", "exec")

def test_compile_ast(self):
Expand Down
2 changes: 1 addition & 1 deletion Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ validate_expr(struct validator *state, expr_ty exp, expr_context_ty ctx)
break;
case NamedExpr_kind:
if (exp->v.NamedExpr.target->kind != Name_kind) {
PyErr_SetString(PyExc_ValueError,
PyErr_SetString(PyExc_TypeError,
"NamedExpr target must be a Name");
return 0;
}
Expand Down

0 comments on commit cd999bf

Please sign in to comment.