summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-06-08 09:22:06 (GMT)
committerGitHub <noreply@github.com>2020-06-08 09:22:06 (GMT)
commit8df4f3942faf05790efeaf62a8f493aabd181d3f (patch)
treeb274a8451e223df94d1cb35e3b6fca1ec96fd724 /Grammar
parent66605d15722e07e4094fc748e2f8ef60fb92f722 (diff)
downloadcpython-8df4f3942faf05790efeaf62a8f493aabd181d3f.zip
cpython-8df4f3942faf05790efeaf62a8f493aabd181d3f.tar.gz
cpython-8df4f3942faf05790efeaf62a8f493aabd181d3f.tar.bz2
bpo-40903: Handle multiple '=' in invalid assignment rules in the PEG parser (GH-20697)
Automerge-Triggered-By: @pablogsal (cherry picked from commit 9f495908c5bd3645ed1af82d7bae6782720dab77) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram5
1 files changed, 3 insertions, 2 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 19d9bb3..dd425ef 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -92,7 +92,7 @@ assignment[stmt_ty]:
| a=('(' b=single_target ')' { b }
| single_subscript_attribute_target) ':' b=expression c=['=' d=annotated_rhs { d }] {
CHECK_VERSION(6, "Variable annotations syntax is", _Py_AnnAssign(a, b, c, 0, EXTRA)) }
- | a=(z=star_targets '=' { z })+ b=(yield_expr | star_expressions) tc=[TYPE_COMMENT] {
+ | a=(z=star_targets '=' { z })+ b=(yield_expr | star_expressions) !'=' tc=[TYPE_COMMENT] {
_Py_Assign(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
| a=single_target b=augassign c=(yield_expr | star_expressions) {
_Py_AugAssign(a, b->kind, c, EXTRA) }
@@ -646,10 +646,11 @@ invalid_assignment:
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") }
| a=expression ':' expression ['=' annotated_rhs] {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "illegal target for annotation") }
- | a=star_expressions '=' (yield_expr | star_expressions) {
+ | (star_targets '=')* a=star_expressions '=' {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
_PyPegen_get_invalid_target(a),
"cannot assign to %s", _PyPegen_get_expr_name(_PyPegen_get_invalid_target(a))) }
+ | (star_targets '=')* a=yield_expr '=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "assignment to yield expression not possible") }
| a=star_expressions augassign (yield_expr | star_expressions) {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
a,