Skip to content

Commit 78e0dcb

Browse files
Commit
1 parent 881144f commit 78e0dcb

File tree

9 files changed

+19
-18
lines changed

9 files changed

+19
-18
lines changed

Grammar/python.gram

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ invalid_dict_comprehension:
13051305
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "dict unpacking cannot be used in dict comprehension") }
13061306
invalid_parameters:
13071307
| a="/" ',' {
1308-
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "at least one argument must precede /") }
1308+
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "at least one parameter must precede /") }
13091309
| (slash_no_default | slash_with_default) param_maybe_default* a='/' {
13101310
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "/ may appear only once") }
13111311
| slash_no_default? param_no_default* invalid_parameters_helper a=param_no_default {
@@ -1333,7 +1333,7 @@ invalid_parameters_helper: # This is only there to avoid type errors
13331333
| param_with_default+
13341334
invalid_lambda_parameters:
13351335
| a="/" ',' {
1336-
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "at least one argument must precede /") }
1336+
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "at least one parameter must precede /") }
13371337
| (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* a='/' {
13381338
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "/ may appear only once") }
13391339
| lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper a=lambda_param_no_default {

Lib/test/test_codeop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def test_syntax_errors(self):
322322
dedent("""\
323323
def foo(x,x):
324324
pass
325-
"""), "duplicate argument 'x' in function definition")
325+
"""), "duplicate parameter 'x' in function definition")
326326

327327

328328

Lib/test/test_positional_only_arg.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def test_invalid_syntax_errors(self):
3737
check_syntax_error(self, "def f(/): pass")
3838
check_syntax_error(self, "def f(*, a, /): pass")
3939
check_syntax_error(self, "def f(*, /, a): pass")
40-
check_syntax_error(self, "def f(a, /, a): pass", "duplicate argument 'a' in function definition")
41-
check_syntax_error(self, "def f(a, /, *, a): pass", "duplicate argument 'a' in function definition")
40+
check_syntax_error(self, "def f(a, /, a): pass", "duplicate parameter 'a' in function definition")
41+
check_syntax_error(self, "def f(a, /, *, a): pass", "duplicate parameter 'a' in function definition")
4242
check_syntax_error(self, "def f(a, b/2, c): pass")
4343
check_syntax_error(self, "def f(a, /, c, /): pass")
4444
check_syntax_error(self, "def f(a, /, c, /, d): pass")
@@ -59,8 +59,8 @@ def test_invalid_syntax_errors_async(self):
5959
check_syntax_error(self, "async def f(/): pass")
6060
check_syntax_error(self, "async def f(*, a, /): pass")
6161
check_syntax_error(self, "async def f(*, /, a): pass")
62-
check_syntax_error(self, "async def f(a, /, a): pass", "duplicate argument 'a' in function definition")
63-
check_syntax_error(self, "async def f(a, /, *, a): pass", "duplicate argument 'a' in function definition")
62+
check_syntax_error(self, "async def f(a, /, a): pass", "duplicate parameter 'a' in function definition")
63+
check_syntax_error(self, "async def f(a, /, *, a): pass", "duplicate parameter 'a' in function definition")
6464
check_syntax_error(self, "async def f(a, b/2, c): pass")
6565
check_syntax_error(self, "async def f(a, /, c, /): pass")
6666
check_syntax_error(self, "async def f(a, /, c, /, d): pass")
@@ -247,8 +247,8 @@ def test_invalid_syntax_lambda(self):
247247
check_syntax_error(self, "lambda /: None")
248248
check_syntax_error(self, "lambda *, a, /: None")
249249
check_syntax_error(self, "lambda *, /, a: None")
250-
check_syntax_error(self, "lambda a, /, a: None", "duplicate argument 'a' in function definition")
251-
check_syntax_error(self, "lambda a, /, *, a: None", "duplicate argument 'a' in function definition")
250+
check_syntax_error(self, "lambda a, /, a: None", "duplicate parameter 'a' in function definition")
251+
check_syntax_error(self, "lambda a, /, *, a: None", "duplicate parameter 'a' in function definition")
252252
check_syntax_error(self, "lambda a, /, b, /: None")
253253
check_syntax_error(self, "lambda a, /, b, /, c: None")
254254
check_syntax_error(self, "lambda a, /, b, /, c, *, d: None")

Lib/test/test_pyrepl/test_interact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_runsource_show_syntax_error_location(self):
113113
r = """
114114
def f(x, x): ...
115115
^
116-
SyntaxError: duplicate argument 'x' in function definition"""
116+
SyntaxError: duplicate parameter 'x' in function definition"""
117117
self.assertIn(r, f.getvalue())
118118

119119
def test_runsource_shows_syntax_error_for_failed_compilation(self):

Lib/test/test_repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def test_runsource_show_syntax_error_location(self):
197197
expected_lines = [
198198
' def f(x, x): ...',
199199
' ^',
200-
"SyntaxError: duplicate argument 'x' in function definition"
200+
"SyntaxError: duplicate parameter 'x' in function definition"
201201
]
202202
self.assertEqual(output.splitlines()[4:-1], expected_lines)
203203

Lib/test/test_syntax.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@
419419
>>> def foo(/,a,b=,c):
420420
... pass
421421
Traceback (most recent call last):
422-
SyntaxError: at least one argument must precede /
422+
SyntaxError: at least one parameter must precede /
423423
424424
>>> def foo(a,/,/,b,c):
425425
... pass
@@ -538,7 +538,7 @@
538538
539539
>>> lambda /,a,b,c: None
540540
Traceback (most recent call last):
541-
SyntaxError: at least one argument must precede /
541+
SyntaxError: at least one parameter must precede /
542542
543543
>>> lambda a,/,/,b,c: None
544544
Traceback (most recent call last):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Correct usage of *arguments* in error messages.

Parser/parser.c

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/symtable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ static void dump_symtable(PySTEntryObject* ste)
380380
}
381381
#endif
382382

383-
#define DUPLICATE_ARGUMENT \
384-
"duplicate argument '%U' in function definition"
383+
#define DUPLICATE_PARAMETER \
384+
"duplicate parameter '%U' in function definition"
385385

386386
static struct symtable *
387387
symtable_new(void)
@@ -1494,7 +1494,7 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s
14941494
}
14951495
if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
14961496
/* Is it better to use 'mangled' or 'name' here? */
1497-
PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT, name);
1497+
PyErr_Format(PyExc_SyntaxError, DUPLICATE_PARAMETER, name);
14981498
SET_ERROR_LOCATION(st->st_filename, loc);
14991499
goto error;
15001500
}

0 commit comments

Comments
 (0)