bpo-40903: Handle multiple '=' in invalid assignment rules in the PEG parser (GH-20697)

Automerge-Triggered-By: @pablogsal
This commit is contained in:
Pablo Galindo 2020-06-08 02:57:00 +01:00 committed by GitHub
parent 843c277656
commit 9f495908c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 558 additions and 342 deletions

View file

@ -63,6 +63,10 @@ SyntaxError: cannot assign to __debug__
Traceback (most recent call last):
SyntaxError: cannot assign to function call
>>> yield = 1
Traceback (most recent call last):
SyntaxError: assignment to yield expression not possible
>>> del f()
Traceback (most recent call last):
SyntaxError: cannot delete function call
@ -136,6 +140,18 @@ SyntaxError: cannot assign to operator
Traceback (most recent call last):
SyntaxError: cannot assign to conditional expression
>>> True = True = 3
Traceback (most recent call last):
SyntaxError: cannot assign to True
>>> x = y = True = z = 3
Traceback (most recent call last):
SyntaxError: cannot assign to True
>>> x = y = yield = 1
Traceback (most recent call last):
SyntaxError: assignment to yield expression not possible
>>> a, b += 1, 2
Traceback (most recent call last):
SyntaxError: 'tuple' is an illegal expression for augmented assignment
@ -148,6 +164,10 @@ SyntaxError: 'tuple' is an illegal expression for augmented assignment
Traceback (most recent call last):
SyntaxError: 'list' is an illegal expression for augmented assignment
>>> p = p =
Traceback (most recent call last):
SyntaxError: invalid syntax
From compiler_complex_args():
>>> def f(None=1):
@ -155,7 +175,6 @@ From compiler_complex_args():
Traceback (most recent call last):
SyntaxError: invalid syntax
From ast_for_arguments():
>>> def f(x, y=1, z):