mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-45450: Improve syntax error for parenthesized arguments (GH-28906)
This commit is contained in:
parent
9852339145
commit
7a1d932528
4 changed files with 893 additions and 445 deletions
|
@ -909,6 +909,44 @@ Missing parens after function definition
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: expected '('
|
||||
|
||||
Parenthesized arguments in function definitions
|
||||
|
||||
>>> def f(x, (y, z), w):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Function parameters cannot be parenthesized
|
||||
|
||||
>>> def f((x, y, z, w)):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Function parameters cannot be parenthesized
|
||||
|
||||
>>> def f(x, (y, z, w)):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Function parameters cannot be parenthesized
|
||||
|
||||
>>> def f((x, y, z), w):
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Function parameters cannot be parenthesized
|
||||
|
||||
>>> lambda x, (y, z), w: None
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Lambda expression parameters cannot be parenthesized
|
||||
|
||||
>>> lambda (x, y, z, w): None
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Lambda expression parameters cannot be parenthesized
|
||||
|
||||
>>> lambda x, (y, z, w): None
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Lambda expression parameters cannot be parenthesized
|
||||
|
||||
>>> lambda (x, y, z), w: None
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Lambda expression parameters cannot be parenthesized
|
||||
|
||||
Custom error messages for try blocks that are not followed by except/finally
|
||||
|
||||
>>> try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue