diff options
author | Collin Winter <collinw@gmail.com> | 2007-03-16 04:12:48 +0000 |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-03-16 04:12:48 +0000 |
commit | 7d9ac783840319a9e83d9b2aef679c4609a48e3f (patch) | |
tree | 0bbd508235305ee0caffd76412b358038fcf2be0 /Lib/test/test_syntax.py | |
parent | c1b4e8e6e2b08b14a1fe1078aa2e6efde1bf7866 (diff) | |
download | cpython-git-7d9ac783840319a9e83d9b2aef679c4609a48e3f.tar.gz |
Patch #1642547: Fix an error/crash when encountering syntax errors in complex if statements.
Backported from r54404.
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 40991492a4..ef8e9a24c6 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -364,6 +364,56 @@ build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514 ... SystemError: too many statically nested blocks +This tests assignment-context; there was a bug in Python 2.5 where compiling +a complex 'if' (one with 'elif') would fail to notice an invalid suite, +leading to spurious errors. + + >>> if 1: + ... x() = 1 + ... elif 1: + ... pass + Traceback (most recent call last): + ... + SyntaxError: can't assign to function call (<doctest test.test_syntax[44]>, line 2) + + >>> if 1: + ... pass + ... elif 1: + ... x() = 1 + Traceback (most recent call last): + ... + SyntaxError: can't assign to function call (<doctest test.test_syntax[45]>, line 4) + + >>> if 1: + ... x() = 1 + ... elif 1: + ... pass + ... else: + ... pass + Traceback (most recent call last): + ... + SyntaxError: can't assign to function call (<doctest test.test_syntax[46]>, line 2) + + >>> if 1: + ... pass + ... elif 1: + ... x() = 1 + ... else: + ... pass + Traceback (most recent call last): + ... + SyntaxError: can't assign to function call (<doctest test.test_syntax[47]>, line 4) + + >>> if 1: + ... pass + ... elif 1: + ... pass + ... else: + ... x() = 1 + Traceback (most recent call last): + ... + SyntaxError: can't assign to function call (<doctest test.test_syntax[48]>, line 6) + """ import re |