diff options
author | Miguel Brito <5544985+miguendes@users.noreply.github.com> | 2021-08-02 18:11:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-02 18:11:37 +0100 |
commit | 28b6dc9dd5d1ce6f8aff7e06d4ef9afdc2bc8332 (patch) | |
tree | 7588a22ecc75a5ea73476644d56dbc9d0fd8659e /Lib/test/test_syntax.py | |
parent | aa0894b3792901adb91e5f6d049154b7bcb980ec (diff) | |
download | cpython-28b6dc9dd5d1ce6f8aff7e06d4ef9afdc2bc8332.tar.gz cpython-28b6dc9dd5d1ce6f8aff7e06d4ef9afdc2bc8332.zip |
bpo-44792: Improve syntax errors for if expressions (GH-27506)
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 6e1531e8b25..d5a52ba628a 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -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 |