From e82f5b5c33c65c09c166fd5421b395a719f4eb00 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 11 Sep 2007 16:39:51 -0700 Subject: [PATCH] Type check after (not before) operation on inplace assignment. --- Cython/Compiler/Nodes.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) -- 2.26.2