From b61ff76eb20e75f2cabda9ca103904424c0ae41a Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Sat, 25 Apr 2009 20:58:37 +0200 Subject: [PATCH] Fix tuple unpacking bug (related to old temps) --- Cython/Compiler/ExprNodes.py | 5 +++-- tests/run/tupleunpack_Thmm.pyx | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/run/tupleunpack_Thmm.pyx diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 25f655a5..b8d41ec0 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 index 00000000..87f24bb9 --- /dev/null +++ b/tests/run/tupleunpack_Thmm.pyx @@ -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 -- 2.26.2