fix bug 409: use cascaded assignments also for the complete rhs when optimising paral...
authorStefan Behnel <scoder@users.berlios.de>
Fri, 23 Oct 2009 08:10:14 +0000 (10:10 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 23 Oct 2009 08:10:14 +0000 (10:10 +0200)
Cython/Compiler/Parsing.py
tests/bugs.txt
tests/run/extended_unpacking_T409.pyx

index 2f28af049f258813aae723c2147e09c66ad1cf3f..c163d35b7c0963027f283a2925a1ddec27d9210c 100644 (file)
@@ -928,6 +928,8 @@ def flatten_parallel_assignments(input, output):
         output.append(input)
         return
 
+    complete_assignments = [rhs]
+
     rhs_size = len(rhs.args)
     lhs_targets = [ [] for _ in range(rhs_size) ]
     starred_assignments = []
@@ -935,7 +937,7 @@ def flatten_parallel_assignments(input, output):
         if not lhs.is_sequence_constructor:
             if lhs.is_starred:
                 error(lhs.pos, "starred assignment target must be in a list or tuple")
-            output.append([lhs,rhs])
+            complete_assignments.append(lhs)
             continue
         lhs_size = len(lhs.args)
         starred_targets = sum([1 for expr in lhs.args if expr.is_starred])
@@ -966,6 +968,9 @@ def flatten_parallel_assignments(input, output):
                 for targets, expr in zip(lhs_targets, lhs.args):
                     targets.append(expr)
 
+    if len(complete_assignments) > 1:
+        output.append(complete_assignments[::-1])
+
     # recursively flatten partial assignments
     for cascade, rhs in zip(lhs_targets, rhs.args):
         if cascade:
index 58205179cf7cbec06a98104c191a51931362fc09..31d6ff3a85e7a844e75046f3a61098b3c86cf220 100644 (file)
@@ -7,4 +7,3 @@ numpy_ValueError_T172
 unsignedbehaviour_T184
 bad_c_struct_T252
 missing_baseclass_in_predecl_T262
-extended_unpacking_T409
index a58b84d474f3c1525f0fef5a6a3dedde4ba62fe6..65cf23e44f07c4a5fdb605ba33785ca765bc0b0d 100644 (file)
@@ -1,14 +1,24 @@
-__doc__ = """
-    >>> simple()
-    (1, 2, [1, 2], [1, 2])
-    >>> extended()
-    (1, (), 2, [1, 2], [1, 2])
-"""
 
 def simple():
+    """
+    >>> simple()
+    ([1, 2], [1, 2])
+    """
+    d = e = [1,2]
+    return d, e
+
+def simple_parallel():
+    """
+    >>> simple_parallel()
+    (1, 2, [1, 2], [1, 2])
+    """
     a, c = d = e = [1,2]
     return a, c, d, e
 
 def extended():
+    """
+    >>> extended()
+    (1, [], 2, [1, 2], [1, 2])
+    """
     a, *b, c = d = e = [1,2]
     return a, b, c, d, e