mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-44792: Improve syntax errors for if expressions (GH-27506) (GH-27565)
(cherry picked from commit 28b6dc9dd5)
Co-authored-by: Miguel Brito <5544985+miguendes@users.noreply.github.com>
This commit is contained in:
parent
c6e7c9860d
commit
567176249e
5 changed files with 48 additions and 0 deletions
|
|
@ -140,6 +140,18 @@
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to conditional expression
|
||||
|
||||
>>> a = 42 if True
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: expected 'else' after 'if' expression
|
||||
|
||||
>>> a = (42 if True)
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: expected 'else' after 'if' expression
|
||||
|
||||
>>> a = [1, 42 if True, 4]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: expected 'else' after 'if' expression
|
||||
|
||||
>>> True = True = 3
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue