Index: Python/ast.c =================================================================== --- Python/ast.c (revision 64561) +++ Python/ast.c (working copy) @@ -1912,6 +1912,8 @@ else { keyword_ty kw; identifier key; + char *tmp; + int k; /* CHILD(ch, 0) is test, but must be an identifier? */ e = ast_for_expr(c, CHILD(ch, 0)); @@ -1933,6 +1935,13 @@ key = e->v.Name.id; if (!forbidden_check(c, CHILD(ch, 0), PyBytes_AS_STRING(key))) return NULL; + for (k = 0; k < nkeywords; k++) { + tmp = PyString_AS_STRING(((keyword_ty)asdl_seq_GET(keywords, k))->arg); + if (!strcmp(tmp, PyString_AS_STRING(key))) { + ast_error(CHILD(ch, 0), "keyword argument repeated"); + return NULL; + } + } e = ast_for_expr(c, CHILD(ch, 2)); if (!e) return NULL; Index: Lib/test/test_grammar.py =================================================================== --- Lib/test/test_grammar.py (revision 64561) +++ Lib/test/test_grammar.py (working copy) @@ -285,6 +285,7 @@ # Check ast errors in *args and *kwargs check_syntax_error(self, "f(*g(1=2))") check_syntax_error(self, "f(**g(1=2))") + check_syntax_error(self, "f(a=23, a=43)") def testLambdef(self): ### lambdef: 'lambda' [varargslist] ':' test