diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2020-06-26 23:14:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-26 23:14:12 (GMT) |
commit | d01a3e76ee0519cba3ccdb5de47b25ec2ed7bee4 (patch) | |
tree | 6d00aa4f9ab93c81edefe9af2ee548a607269f45 /Grammar | |
parent | f925407a19eeb9bf5f7640143979638adce2c677 (diff) | |
download | cpython-d01a3e76ee0519cba3ccdb5de47b25ec2ed7bee4.zip cpython-d01a3e76ee0519cba3ccdb5de47b25ec2ed7bee4.tar.gz cpython-d01a3e76ee0519cba3ccdb5de47b25ec2ed7bee4.tar.bz2 |
[3.9] bpo-41119: Output correct error message for list/tuple followed by colon (GH-21160) (GH-21172)
(cherry picked from commit 4b85e60601489f9ee9dd2909e28d89a31566887c)
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 8e6174f..8159f83 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -648,18 +648,18 @@ invalid_named_expression: RAISE_SYNTAX_ERROR_KNOWN_LOCATION( a, "cannot use assignment expressions with %s", _PyPegen_get_expr_name(a)) } invalid_assignment: - | a=list ':' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not list) can be annotated") } - | a=tuple ':' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") } - | a=star_named_expression ',' star_named_expressions* ':' { + | a=list ':' expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not list) can be annotated") } + | a=tuple ':' expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") } + | a=star_named_expression ',' star_named_expressions* ':' expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") } - | a=expression ':' expression ['=' annotated_rhs] { + | a=expression ':' expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "illegal target for annotation") } | (star_targets '=')* a=star_expressions '=' { RAISE_SYNTAX_ERROR_INVALID_TARGET(STAR_TARGETS, 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, + a, "'%s' is an illegal expression for augmented assignment", _PyPegen_get_expr_name(a) )} |