Fix tuple unpacking bug (related to old temps)
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 25 Apr 2009 18:58:37 +0000 (20:58 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 25 Apr 2009 18:58:37 +0000 (20:58 +0200)
Cython/Compiler/ExprNodes.py
tests/run/tupleunpack_Thmm.pyx [new file with mode: 0644]

index 25f655a5b7877b8d9e692bb31c9aa7e96a5087a8..b8d41ec04b65de1f9b18dbbdb2e82dcaf99a06d6 100644 (file)
@@ -3003,11 +3003,12 @@ class SequenceNode(NewTempExprNode):
     
     def allocate_target_temps(self, env, rhs):
         self.iterator.allocate_temps(env)
-        for arg, node in zip(self.args, self.coerced_unpacked_items):
+        for node in self.coerced_unpacked_items:
             node.allocate_temps(env)
-            arg.allocate_target_temps(env, None)
             #arg.release_target_temp(env)
             #node.release_temp(env)
+        for arg in self.args:
+            arg.allocate_target_temps(env, None)
         if rhs:
             rhs.release_temp(env)
         self.iterator.release_temp(env)
diff --git a/tests/run/tupleunpack_Thmm.pyx b/tests/run/tupleunpack_Thmm.pyx
new file mode 100644 (file)
index 0000000..87f24bb
--- /dev/null
@@ -0,0 +1,25 @@
+"""
+>>> func()
+0 0
+0
+0
+1 1
+1
+1
+2 2
+2
+2
+>>> func2()
+"""
+
+def g():
+    return ((3, 2), 1, 0)
+
+def func2():
+    (a, b), c, d = g()
+
+def func():
+    for (a, b),c ,d in zip(zip(range(3), range(3)), range(3), range(3)):
+        print a, b
+        print c
+        print d