From: Stefan Behnel Date: Mon, 6 Apr 2009 17:13:25 +0000 (+0200) Subject: disable some constant folding operations that can break code X-Git-Tag: 0.11.1.beta~12 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fe68a83eca5d98dcdcdfa568d9006425df23e09f;p=cython.git disable some constant folding operations that can break code --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 0b03f894..94aaf861 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -877,7 +877,9 @@ class FloatNode(ConstNode): type = PyrexTypes.c_double_type def calculate_constant_result(self): - self.constant_result = float(self.value) + # calculating float values is usually not a good idea + #self.constant_result = float(self.value) + pass def compile_time_value(self, denv): return float(self.value) @@ -3889,7 +3891,9 @@ class TypecastNode(NewTempExprNode): self.operand.check_const() def calculate_constant_result(self): - self.constant_result = self.operand.constant_result + # we usually do not know the result of a type cast at code + # generation time + pass def calculate_result_code(self): opnd = self.operand @@ -4949,7 +4953,8 @@ class CoercionNode(NewTempExprNode): print("%s Coercing %s" % (self, self.arg)) def calculate_constant_result(self): - self.constant_result = self.arg.constant_result + # constant folding can break type coercion, so this is disabled + pass def annotate(self, code): self.arg.annotate(code)