mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-43797: Handle correctly invalid assignments inside function calls and generators (GH-25390)
This commit is contained in:
parent
fd79af7ae2
commit
30ed93bfec
4 changed files with 21 additions and 9 deletions
|
@ -868,6 +868,18 @@ Ensure that early = are not matched by the parser as invalid comparisons
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
>>> dict(x=34); x $ y
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
>>> dict(x=34, (x for x in range 10), 1); x $ y
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
>>> dict(x=34, x=1, y=2); x $ y
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
Make sure that the old "raise X, Y[, Z]" form is gone:
|
||||
>>> raise X, Y
|
||||
Traceback (most recent call last):
|
||||
|
@ -1013,7 +1025,7 @@ class SyntaxTestCase(unittest.TestCase):
|
|||
def test_expression_with_assignment(self):
|
||||
self._check_error(
|
||||
"print(end1 + end2 = ' ')",
|
||||
"cannot assign to expression here. Maybe you meant '==' instead of '='?",
|
||||
'expression cannot contain assignment, perhaps you meant "=="?',
|
||||
offset=19
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue