mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-45716: Improve the error message when using True/False/None as keywords in a call (GH-29413)
This commit is contained in:
parent
32f55d1a5d
commit
e2d65630f3
4 changed files with 1553 additions and 1437 deletions
|
@ -1062,6 +1062,8 @@ invalid_arguments:
|
||||||
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, asdl_seq_GET(b, b->size-1)->target, "Generator expression must be parenthesized") }
|
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, asdl_seq_GET(b, b->size-1)->target, "Generator expression must be parenthesized") }
|
||||||
| a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
|
| a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
|
||||||
invalid_kwarg:
|
invalid_kwarg:
|
||||||
|
| a[Token*]=('True'|'False'|'None') b='=' {
|
||||||
|
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to %s", PyBytes_AS_STRING(a->bytes)) }
|
||||||
| a=NAME b='=' expression for_if_clauses {
|
| a=NAME b='=' expression for_if_clauses {
|
||||||
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?")}
|
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?")}
|
||||||
| !(NAME '=') a=expression b='=' {
|
| !(NAME '=') a=expression b='=' {
|
||||||
|
|
|
@ -524,9 +524,15 @@ SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
|
||||||
>>> f((x)=2)
|
>>> f((x)=2)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
|
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
|
||||||
>>> f(True=2)
|
>>> f(True=1)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
|
SyntaxError: cannot assign to True
|
||||||
|
>>> f(False=1)
|
||||||
|
Traceback (most recent call last):
|
||||||
|
SyntaxError: cannot assign to False
|
||||||
|
>>> f(None=1)
|
||||||
|
Traceback (most recent call last):
|
||||||
|
SyntaxError: cannot assign to None
|
||||||
>>> f(__debug__=1)
|
>>> f(__debug__=1)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
SyntaxError: cannot assign to __debug__
|
SyntaxError: cannot assign to __debug__
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Improve the :exc:`SyntaxError` message when using ``True``, ``None`` or
|
||||||
|
``False`` as keywords in a function call. Patch by Pablo Galindo.
|
2976
Parser/parser.c
2976
Parser/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue