item.result(),
i))
code.put_incref(item.result(), item.ctype())
+ value_node = self.coerced_unpacked_items[i]
+ value_node.generate_evaluation_code(code)
rhs.generate_disposal_code(code)
+
code.putln("} else {")
code.putln(
item.result(),
typecast(item.ctype(), py_object_type, unpack_code),
code.error_goto_if_null(item.result(), self.pos)))
+ value_node = self.coerced_unpacked_items[i]
+ value_node.generate_evaluation_code(code)
code.put_error_if_neg(self.pos,
"__Pyx_EndUnpack(%s)" % (
self.iterator.py_result()))
code.putln("}")
for i in range(len(self.args)):
- value_node = self.coerced_unpacked_items[i]
- value_node.generate_evaluation_code(code)
- self.args[i].generate_assignment_code(value_node, code)
+ self.args[i].generate_assignment_code(
+ self.coerced_unpacked_items[i], code)
def annotate(self, code):
for arg in self.args:
(1, 2, 3)
>>> assign3(t)
(1, 2, 3)
->>>
+>>> assign3_int(l)
+(1, 2, 3)
+>>> assign3_mixed1(l)
+(1, 2, 3)
+>>> assign3_mixed2(l)
+(1, 2, 3)
+>>> assign3_mixed3(l)
+(1, 2, 3)
->>> a,b = 99,99
+>>> a,b = 99,98
>>> a,b = t
Traceback (most recent call last):
ValueError: too many values to unpack
>>> a,b
-(99, 99)
+(99, 98)
>>> test_overwrite(l)
-(99, 99)
+(99, 98)
>>> test_overwrite(t)
-(99, 99)
+(99, 98)
+
+>>> test_overwrite_int(l)
+(99, 98)
+>>> test_overwrite_int(t)
+(99, 98)
+
+>>> test_overwrite_mixed(l)
+(99, 98)
+>>> test_overwrite_mixed(t)
+(99, 98)
+
+>>> test_overwrite_mixed2(l)
+(99, 98)
+>>> test_overwrite_mixed2(t)
+(99, 98)
"""
t = (1,2,3)
a,b,c = t
return (a,b,c)
+def assign3_int(t):
+ cdef int a,b,c
+ a,b,c = t
+ return (a,b,c)
+
+def assign3_mixed1(t):
+ cdef int a
+ a,b,c = t
+ return (a,b,c)
+
+def assign3_mixed2(t):
+ cdef int b
+ a,b,c = t
+ return (a,b,c)
+
+def assign3_mixed3(t):
+ cdef int c
+ a,b,c = t
+ return (a,b,c)
+
+def assign3_mixed4(t):
+ cdef int b,c
+ a,b,c = t
+ return (a,b,c)
+
def test_overwrite(t):
- a,b = 99,99
+ a,b = 99,98
+ try:
+ a,b = t
+ except ValueError:
+ pass
+ return (a,b)
+
+def test_overwrite_int(t):
+ cdef int a,b
+ a,b = 99,98
+ try:
+ a,b = t
+ except ValueError:
+ pass
+ return (a,b)
+
+def test_overwrite_mixed(t):
+ cdef int b
+ a,b = 99,98
+ try:
+ a,b = t
+ except ValueError:
+ pass
+ return (a,b)
+
+def test_overwrite_mixed2(t):
+ cdef int a
+ a,b = 99,98
try:
a,b = t
except ValueError: