diff options
author | Batuhan Taskaya <batuhanosmantaskaya@gmail.com> | 2020-05-21 20:41:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 20:41:58 (GMT) |
commit | 72e0aa2fd2b9c6da2caa5a9ef54f6495fc2890b0 (patch) | |
tree | a50b92d182c5a98032efc1cf5d1cfb769ffaad78 /Grammar | |
parent | d10fef35c6ce8a3193b974be7e8c8304b1146153 (diff) | |
download | cpython-72e0aa2fd2b9c6da2caa5a9ef54f6495fc2890b0.zip cpython-72e0aa2fd2b9c6da2caa5a9ef54f6495fc2890b0.tar.gz cpython-72e0aa2fd2b9c6da2caa5a9ef54f6495fc2890b0.tar.bz2 |
bpo-40176: Improve error messages for trailing comma on from import (GH-20294)
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 40e7818..9bf2697 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -134,8 +134,9 @@ import_from[stmt_ty]: _Py_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), EXTRA) } import_from_targets[asdl_seq*]: | '(' a=import_from_as_names [','] ')' { a } - | import_from_as_names + | import_from_as_names !',' | '*' { _PyPegen_singleton_seq(p, CHECK(_PyPegen_alias_for_star(p))) } + | invalid_import_from_targets import_from_as_names[asdl_seq*]: | a=','.import_from_as_name+ { a } import_from_as_name[alias_ty]: @@ -670,3 +671,6 @@ invalid_double_type_comments: invalid_del_target: | a=star_expression &del_target_end { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot delete %s", _PyPegen_get_expr_name(a)) } +invalid_import_from_targets: + | import_from_as_names ',' { + RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") } |