summaryrefslogtreecommitdiffstats
path: root/Grammar/python.gram
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-11-20 18:27:40 (GMT)
committerGitHub <noreply@github.com>2021-11-20 18:27:40 (GMT)
commit7a1d9325287a39528b795b1e8037146777abfe3e (patch)
tree52120380f57212078ce780146a9b09a02ec74ca6 /Grammar/python.gram
parent985233914504c73f14a23af1c68a3709079e6913 (diff)
downloadcpython-7a1d9325287a39528b795b1e8037146777abfe3e.zip
cpython-7a1d9325287a39528b795b1e8037146777abfe3e.tar.gz
cpython-7a1d9325287a39528b795b1e8037146777abfe3e.tar.bz2
bpo-45450: Improve syntax error for parenthesized arguments (GH-28906)
Diffstat (limited to 'Grammar/python.gram')
-rw-r--r--Grammar/python.gram4
1 files changed, 4 insertions, 0 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 168bb3c..60fbc40 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -1140,12 +1140,16 @@ invalid_dict_comprehension:
invalid_parameters:
| param_no_default* invalid_parameters_helper a=param_no_default {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "non-default argument follows default argument") }
+ | param_no_default* a='(' param_no_default+ ','? b=')' {
+ RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "Function parameters cannot be parenthesized") }
invalid_parameters_helper: # This is only there to avoid type errors
| a=slash_with_default { _PyPegen_singleton_seq(p, a) }
| param_with_default+
invalid_lambda_parameters:
| lambda_param_no_default* invalid_lambda_parameters_helper a=lambda_param_no_default {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "non-default argument follows default argument") }
+ | lambda_param_no_default* a='(' ','.lambda_param+ ','? b=')' {
+ RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "Lambda expression parameters cannot be parenthesized") }
invalid_lambda_parameters_helper:
| a=lambda_slash_with_default { _PyPegen_singleton_seq(p, a) }
| lambda_param_with_default+