[3.10] bpo-45716: Improve the error message when using True/False/None as keywords in a call (GH-29413). (GH-29428)
(cherry picked from commit e2d65630f36712dbdbf7711520c985c526a5cc25)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 24f5fb4..7934ccd 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -838,6 +838,8 @@
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, asdl_seq_GET(b, b->size-1)->target, "Generator expression must be parenthesized") }
| a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
invalid_kwarg:
+ | a[Token*]=('True'|'False'|'None') b='=' {
+ RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to %s", PyBytes_AS_STRING(a->bytes)) }
| a=NAME b='=' expression for_if_clauses {
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?")}
| !(NAME '=') a=expression b='=' {