Skip to content

Commit 904941a

Browse files
author
Uno
committed
fix: add explanation without modifying the original message
1 parent 233b9a6 commit 904941a

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

Grammar/python.gram

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,11 +1331,11 @@ invalid_default:
13311331
invalid_star_etc:
13321332
| a='*' (')' | ',' (')' | '**')) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "named parameters must follow bare *") }
13331333
| '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR("bare * has associated type comment") }
1334-
| '*' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional parameter's default value cannot be changed because it has the immutable default value ()") }
1334+
| '*' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional parameter cannot have default value, it's default valude is ()") }
13351335
| '*' (param_no_default | ',') param_maybe_default* a='*' (param_no_default | ',') {
13361336
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* may appear only once") }
13371337
invalid_kwds:
1338-
| '**' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-keyword parameter's default value cannot be changed because it has the immutable default value {}") }
1338+
| '**' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-keyword parameter cannot have default value, it's default valude is {}") }
13391339
| '**' param ',' a=param { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "parameters cannot follow var-keyword parameter") }
13401340
| '**' param ',' a[Token*]=('*'|'**'|'/') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "parameters cannot follow var-keyword parameter") }
13411341
invalid_parameters_helper: # This is only there to avoid type errors
@@ -1359,11 +1359,11 @@ invalid_lambda_parameters_helper:
13591359
| lambda_param_with_default+
13601360
invalid_lambda_star_etc:
13611361
| '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR("named parameters must follow bare *") }
1362-
| '*' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional parameter's default value cannot be changed because it has the immutable default value ()") }
1362+
| '*' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional parameter cannot have default value, it's default valude is ()") }
13631363
| '*' (lambda_param_no_default | ',') lambda_param_maybe_default* a='*' (lambda_param_no_default | ',') {
13641364
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* may appear only once") }
13651365
invalid_lambda_kwds:
1366-
| '**' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-keyword parameter's default value cannot be changed because it has the immutable default value {}") }
1366+
| '**' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-keyword parameter cannot have default value, it's default valude is {}") }
13671367
| '**' lambda_param ',' a=lambda_param { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "parameters cannot follow var-keyword parameter") }
13681368
| '**' lambda_param ',' a[Token*]=('*'|'**'|'/') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "parameters cannot follow var-keyword parameter") }
13691369
invalid_double_type_comments:

Lib/test/test_syntax.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,22 +461,22 @@
461461
>>> def foo(a,*b=3,c):
462462
... pass
463463
Traceback (most recent call last):
464-
SyntaxError: var-positional parameter's default value cannot be changed because it has the immutable default value ()
464+
SyntaxError: var-positional parameter cannot have default value, it's default valude is ()
465465
466466
>>> def foo(a,*b: int=,c):
467467
... pass
468468
Traceback (most recent call last):
469-
SyntaxError: var-positional parameter's default value cannot be changed because it has the immutable default value ()
469+
SyntaxError: var-positional parameter cannot have default value, it's default valude is ()
470470
471471
>>> def foo(a,**b=3):
472472
... pass
473473
Traceback (most recent call last):
474-
SyntaxError: var-keyword parameter's default value cannot be changed because it has the immutable default value {}
474+
SyntaxError: var-keyword parameter cannot have default value, it's default valude is {}
475475
476476
>>> def foo(a,**b: int=3):
477477
... pass
478478
Traceback (most recent call last):
479-
SyntaxError: var-keyword parameter's default value cannot be changed because it has the immutable default value {}
479+
SyntaxError: var-keyword parameter cannot have default value, it's default valude is {}
480480
481481
>>> def foo(a,*a, b, **c, d):
482482
... pass
@@ -577,11 +577,11 @@
577577
578578
>>> lambda a,*b=3,c: None
579579
Traceback (most recent call last):
580-
SyntaxError: var-positional parameter's default value cannot be changed because it has the immutable default value ()
580+
SyntaxError: var-positional parameter cannot have default value, it's default valude is ()
581581
582582
>>> lambda a,**b=3: None
583583
Traceback (most recent call last):
584-
SyntaxError: var-keyword parameter's default value cannot be changed because it has the immutable default value {}
584+
SyntaxError: var-keyword parameter cannot have default value, it's default valude is {}
585585
586586
>>> lambda a, *a, b, **c, d: None
587587
Traceback (most recent call last):

Parser/parser.c

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

0 commit comments

Comments
 (0)