summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unpack_ex.py
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2008-03-14 17:16:59 (GMT)
committerThomas Wouters <thomas@python.org>2008-03-14 17:16:59 (GMT)
commitdeef67481c37965474b64c7e703982998c20a654 (patch)
tree93b07813979e474cb4eec489c599d1ddb6495584 /Lib/test/test_unpack_ex.py
parent4a983c550e546a0cd3bb9349d301ac7cd0017c50 (diff)
downloadcpython-deef67481c37965474b64c7e703982998c20a654.zip
cpython-deef67481c37965474b64c7e703982998c20a654.tar.gz
cpython-deef67481c37965474b64c7e703982998c20a654.tar.bz2
Fix crasher in unpacking assignments with star, where the size constraints
weren't checked.
Diffstat (limited to 'Lib/test/test_unpack_ex.py')
-rw-r--r--Lib/test/test_unpack_ex.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py
index 7fe486b..89486b8 100644
--- a/Lib/test/test_unpack_ex.py
+++ b/Lib/test/test_unpack_ex.py
@@ -143,6 +143,23 @@ Now some general starred expressions (all fail).
...
SyntaxError: can use starred expression only as assignment target
+Some size constraints (all fail.)
+
+ >>> s = ", ".join("a%d" % i for i in range(1<<8)) + ", *rest = range(1<<8 + 1)"
+ >>> compile(s, 'test', 'exec') # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: too many expressions in star-unpacking assignment
+
+ >>> s = ", ".join("a%d" % i for i in range(1<<8 + 1)) + ", *rest = range(1<<8 + 2)"
+ >>> compile(s, 'test', 'exec') # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: too many expressions in star-unpacking assignment
+
+(there is an additional limit, on the number of expressions after the
+'*rest', but it's 1<<24 and testing it takes too much memory.)
+
"""
__test__ = {'doctests' : doctests}