bpo-30858: Improve error location for expressions with assignments (GH-23753)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 9f47094..4915cc4 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -646,7 +646,7 @@
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "Generator expression must be parenthesized") }
| a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
invalid_kwarg:
- | a=expression '=' {
+ | expression a='=' {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
a, "expression cannot contain assignment, perhaps you meant \"==\"?") }
invalid_named_expression: