summaryrefslogtreecommitdiff
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-03-16 04:12:48 +0000
committerCollin Winter <collinw@gmail.com>2007-03-16 04:12:48 +0000
commit7d9ac783840319a9e83d9b2aef679c4609a48e3f (patch)
tree0bbd508235305ee0caffd76412b358038fcf2be0 /Lib/test/test_syntax.py
parentc1b4e8e6e2b08b14a1fe1078aa2e6efde1bf7866 (diff)
downloadcpython-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.py50
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