bpo-45450: Improve syntax error for parenthesized arguments (GH-28906)

This commit is contained in:
Pablo Galindo Salgado 2021-11-20 18:27:40 +00:00 committed by GitHub
parent 9852339145
commit 7a1d932528
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 893 additions and 445 deletions

View file

@ -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: