diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index a105e33fd0ef14a3e40f9629d7a02e05c3dc141a..18eb72c7fcddda24340316ad5a58871efc84db06 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1877,6 +1877,27 @@ class SequenceNode(ExprNode): self.generate_operation_code(code) def generate_assignment_code(self, rhs, code): + code.putln( + "if (PyTuple_CheckExact(%s) && PyTuple_GET_SIZE(%s) == %s) {" % ( + rhs.py_result(), + rhs.py_result(), + len(self.args))) + for i in range(len(self.args)): + item = self.unpacked_items[i] + code.putln( + "%s = PyTuple_GET_ITEM(%s, %s);" % ( + item.result_code, + rhs.py_result(), + i)) + code.put_incref(item.result_code, item.ctype()) + value_node = self.coerced_unpacked_items[i] + value_node.generate_evaluation_code(code) + self.args[i].generate_assignment_code(value_node, code) + + rhs.generate_disposal_code(code) + code.putln("}") + code.putln("else {") + code.putln( "%s = PyObject_GetIter(%s); if (!%s) %s" % ( self.iterator.result_code, @@ -1903,9 +1924,11 @@ class SequenceNode(ExprNode): code.error_goto(self.pos))) if debug_disposal_code: print "UnpackNode.generate_assignment_code:" - print "...generating disposal code for", rhs + print "...generating disposal code for", iterator self.iterator.generate_disposal_code(code) + code.putln("}") + class TupleNode(SequenceNode): # Tuple constructor. diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 0e7c392a4ca0f2fc5eedea73ae4020e9ccce969d..8389d77475dcaf08d121884ce80b737404356c6e 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1497,7 +1497,7 @@ def p_c_arg_list(s, in_pyfunc, cmethod_flag = 0): args.append(p_c_arg_decl(s, in_pyfunc, cmethod_flag)) while s.sy == ',': s.next() - if s.sy in c_arg_list_trailers: + if s.sy in c_arg_list_terminators: break args.append(p_c_arg_decl(s, in_pyfunc)) return args diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 64fdcd579745483e512776a2d7e6fcb1289efccb..b25fbc30fb884c3ec0930e60f7cbd9e8c5fc2f65 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -647,6 +647,15 @@ class CStructOrUnionType(CType): base = "%s %s" % (self.kind, self.cname) return "%s %s" % (public_decl(base, dll_linkage), entity_code) + def __cmp__(self, other): + try: + if self.name == other.name: + return 0 + else: + return 1 + except AttributeError: + return 1 + def is_complete(self): return self.scope is not None