mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-111488: Changed error message in case of no 'in' keyword after 'for' in cmp (#113656)
This commit is contained in:
parent
bbf214df23
commit
bb4c167060
5 changed files with 3082 additions and 2854 deletions
|
@ -259,6 +259,36 @@ SyntaxError: expected ':'
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
Comprehensions without 'in' keyword:
|
||||
|
||||
>>> [x for x if range(1)]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: 'in' expected after for-loop variables
|
||||
|
||||
>>> tuple(x for x if range(1))
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: 'in' expected after for-loop variables
|
||||
|
||||
>>> [x for x() in a]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to function call
|
||||
|
||||
>>> [x for a, b, (c + 1, d()) in y]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to expression
|
||||
|
||||
>>> [x for a, b, (c + 1, d()) if y]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: 'in' expected after for-loop variables
|
||||
|
||||
>>> [x for x+1 in y]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to expression
|
||||
|
||||
>>> [x for x+1, x() in y]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to expression
|
||||
|
||||
Comprehensions creating tuples without parentheses
|
||||
should produce a specialized error message:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue