From ffce516a4b8ac12cf98bd601cf9ad66a20b710d5 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sun, 20 Mar 2022 14:12:49 -0700 Subject: [PATCH] bpo-47054: Call params parameters not arguments in SyntaxErrors. A couple of SyntaxErrors were potentionally confusing in their wording due to the use of the term arguments when what it was referring are pedantically parameters as the errors happen at definition time. We unfortunately use the terms loosely in various parts of Python. https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter#:~:text=A%20parameter%20is%20the%20variable,function%20when%20it%20is%20called. --- Grammar/python.gram | 8 ++++---- Parser/parser.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index c0a64696e85dc6..fd80e5e7ce9ae5 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -1148,7 +1148,7 @@ invalid_dict_comprehension: RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "dict unpacking cannot be used in 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") } + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "non-keyword parameter follows keyword parameter") } | 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 @@ -1156,17 +1156,17 @@ invalid_parameters_helper: # This is only there to avoid type errors | 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") } + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "non-keyword parameter follows keyword parameter") } | 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+ invalid_star_etc: - | a='*' (')' | ',' (')' | '**')) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "named arguments must follow bare *") } + | a='*' (')' | ',' (')' | '**')) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "named parameters must follow bare *") } | '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR("bare * has associated type comment") } invalid_lambda_star_etc: - | '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR("named arguments must follow bare *") } + | '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR("named parameters must follow bare *") } invalid_double_type_comments: | TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT { RAISE_SYNTAX_ERROR("Cannot have two type comments on def") } diff --git a/Parser/parser.c b/Parser/parser.c index 7f2d125996d2fc..f2ac9fc027ad5d 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -19861,7 +19861,7 @@ invalid_parameters_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* invalid_parameters_helper param_no_default")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "non-default argument follows default argument" ); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "non-keyword parameter follows keyword parameter" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20013,7 +20013,7 @@ invalid_lambda_parameters_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "non-default argument follows default argument" ); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "non-keyword parameter follows keyword parameter" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20162,7 +20162,7 @@ invalid_star_etc_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "named arguments must follow bare *" ); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "named parameters must follow bare *" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20239,7 +20239,7 @@ invalid_lambda_star_etc_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); - _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); + _res = RAISE_SYNTAX_ERROR ( "named parameters must follow bare *" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--;