diff options
| author | Carl Friedrich Bolz-Tereick <cfbolz@gmx.de> | 2021-11-09 15:03:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-09 06:03:32 -0800 |
| commit | 2819e98d1048238bf94dc2ba88ae2455d01861bc (patch) | |
| tree | 3c6e0d26fd6dd869a17ac148299b824531c48174 /Grammar | |
| parent | f4c03484da59049eb62a9bf7777b963e2267d187 (diff) | |
| download | cpython-git-2819e98d1048238bf94dc2ba88ae2455d01861bc.tar.gz | |
bpo-45764: improve error message when missing '(' after 'def' (GH-29484)
to achieve this, change the grammar to expect the '(' token after 'def' NAME.
Automerge-Triggered-By: GH:pablogsal
Diffstat (limited to 'Grammar')
| -rw-r--r-- | Grammar/python.gram | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index ffe035f037..d1901a5a9a 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -264,11 +264,11 @@ function_def[stmt_ty]: function_def_raw[stmt_ty]: | invalid_def_raw - | 'def' n=NAME '(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { + | 'def' n=NAME &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { _PyAST_FunctionDef(n->v.Name.id, (params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)), b, NULL, a, NEW_TYPE_COMMENT(p, tc), EXTRA) } - | ASYNC 'def' n=NAME '(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { + | ASYNC 'def' n=NAME &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { CHECK_VERSION( stmt_ty, 5, |
