From f070108ea037bd4e35172183fed4d036f4a125b8 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 12 Nov 2010 21:48:38 +0100 Subject: [PATCH] fix coercion from IntNode to FloatNode, e.g. for hex literals etc. --- Cython/Compiler/ExprNodes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 4743e282..b87d2bef 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -815,8 +815,13 @@ class IntNode(ConstNode): if self.type is dst_type: return self elif dst_type.is_float: - float_value = float(self.value) - return FloatNode(self.pos, value=repr(float_value), constant_result=float_value) + if self.constant_result is not not_a_constant: + float_value = float(self.constant_result) + return FloatNode(self.pos, value=repr(float_value), type=dst_type, + constant_result=float_value) + else: + return FloatNode(self.pos, value=self.value, type=dst_type, + constant_result=not_a_constant) node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, unsigned=self.unsigned, longness=self.longness) if dst_type.is_numeric and not dst_type.is_complex: -- 2.26.2