summaryrefslogtreecommitdiff
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-03-16 04:11:30 +0000
committerCollin Winter <collinw@gmail.com>2007-03-16 04:11:30 +0000
commit77c67bd5858ec0878f3cab93eb4b1ae53186688d (patch)
tree8b0ef17b570b0b87300a65cc2b87440533e23c29 /Lib/test/test_syntax.py
parent20f43d3018e3ff474f761d1a03c18cec3291042b (diff)
downloadcpython-git-77c67bd5858ec0878f3cab93eb4b1ae53186688d.tar.gz
Patch #1642547: Fix an error/crash when encountering syntax errors in complex if statements.
Will backport.
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 f452298098..a6ffec30da 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -367,6 +367,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