bpo-44792: Improve syntax errors for if expressions (GH-27506)

This commit is contained in:
Miguel Brito 2021-08-02 18:11:37 +01:00 committed by GitHub
parent aa0894b379
commit 28b6dc9dd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 0 deletions

View file

@ -140,6 +140,18 @@ SyntaxError: cannot assign to expression
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