From: Robert Bradshaw Date: Tue, 11 Sep 2007 23:39:51 +0000 (-0700) Subject: Type check after (not before) operation on inplace assignment. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e82f5b5c33c65c09c166fd5421b395a719f4eb00;p=cython.git Type check after (not before) operation on inplace assignment. --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index ddbfdda0..0900676a 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1629,10 +1629,12 @@ class InPlaceAssignmentNode(AssignmentNode): def allocate_rhs_temps(self, env): import ExprNodes - if self.lhs.type.is_pyobject or self.rhs.type.is_pyobject: + if self.lhs.type.is_pyobject: + self.rhs = self.rhs.coerce_to_pyobject(env) + elif self.rhs.type.is_pyobject: self.rhs = self.rhs.coerce_to(self.lhs.type, env) if self.lhs.type.is_pyobject: - self.result = ExprNodes.PyTempNode(self.pos, env) + self.result = ExprNodes.PyTempNode(self.pos, env).coerce_to(self.lhs.type, env) self.result.allocate_temps(env) # if use_temp: # self.rhs = self.rhs.coerce_to_temp(env) @@ -1662,6 +1664,7 @@ class InPlaceAssignmentNode(AssignmentNode): self.dup.py_result(), self.rhs.py_result(), code.error_goto_if_null(self.result.py_result(), self.pos))) + self.result.generate_evaluation_code(code) # May be a type check... self.rhs.generate_disposal_code(code) self.dup.generate_disposal_code(code) self.lhs.generate_assignment_code(self.result, code)