mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
[3.11] gh-110696: Fix incorrect syntax error message for incorrect argument unpacking (GH-110706) (#110766)
This commit is contained in:
parent
7c308f4c64
commit
4e4a3e161f
4 changed files with 2114 additions and 1742 deletions
|
|
@ -1075,7 +1075,8 @@ func_type_comment[Token*]:
|
|||
|
||||
# From here on, there are rules for invalid syntax with specialised error messages
|
||||
invalid_arguments:
|
||||
| a=args ',' '*' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "iterable argument unpacking follows keyword argument unpacking") }
|
||||
| ((','.(starred_expression | ( assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' b='*' {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(b, "iterable argument unpacking follows keyword argument unpacking") }
|
||||
| a=expression b=for_if_clauses ',' [args | expression for_if_clauses] {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, _PyPegen_get_last_comprehension_item(PyPegen_last_item(b, comprehension_ty)), "Generator expression must be parenthesized") }
|
||||
| a=NAME b='=' expression for_if_clauses {
|
||||
|
|
|
|||
|
|
@ -1827,6 +1827,17 @@ def f(x: *b)
|
|||
^^^^^^^^^^^
|
||||
SyntaxError: bytes can only contain ASCII literal characters
|
||||
|
||||
>>> f(**x, *y)
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: iterable argument unpacking follows keyword argument unpacking
|
||||
|
||||
>>> f(**x, *)
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: iterable argument unpacking follows keyword argument unpacking
|
||||
|
||||
>>> f(x, *:)
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
"""
|
||||
|
||||
import re
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Fix incorrect error message for invalid argument unpacking. Patch by Pablo
|
||||
Galindo
|
||||
3840
Parser/parser.c
generated
3840
Parser/parser.c
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue