diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2020-10-27 18:54:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-27 18:54:20 (GMT) |
commit | 15acc4eaba8519d7d5f2acaffde65446b44dcf79 (patch) | |
tree | 9e67e28b551fd67a2ffb24e7cc6b7d11b3584db6 /Grammar | |
parent | 95f710c55714153f0c8cce48f8215bb3d866ac1d (diff) | |
download | cpython-15acc4eaba8519d7d5f2acaffde65446b44dcf79.zip cpython-15acc4eaba8519d7d5f2acaffde65446b44dcf79.tar.gz cpython-15acc4eaba8519d7d5f2acaffde65446b44dcf79.tar.bz2 |
bpo-41659: Disallow curly brace directly after primary (GH-22996)
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 19c85ac..b8da554 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -475,6 +475,7 @@ await_primary[expr_ty] (memo): | AWAIT a=primary { CHECK_VERSION(expr_ty, 5, "Await expressions are", _Py_Await(a, EXTRA)) } | primary primary[expr_ty]: + | invalid_primary # must be before 'primay genexp' because of invalid_genexp | a=primary '.' b=NAME { _Py_Attribute(a, b->v.Name.id, Load, EXTRA) } | a=primary b=genexp { _Py_Call(a, CHECK(asdl_expr_seq*, (asdl_expr_seq*)_PyPegen_singleton_seq(p, b)), NULL, EXTRA) } | a=primary '(' b=[arguments] ')' { @@ -682,6 +683,8 @@ invalid_del_stmt: RAISE_SYNTAX_ERROR_INVALID_TARGET(DEL_TARGETS, a) } invalid_block: | NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block") } +invalid_primary: + | primary a='{' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "invalid syntax") } invalid_comprehension: | ('[' | '(' | '{') a=starred_expression for_if_clauses { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "iterable unpacking cannot be used in comprehension") } |