From 5da90229e34b6f7a646cd06afa5b875dd9155a78 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Mon, 19 Jan 2009 17:48:38 -0800 Subject: [PATCH] Must use repr() not str() for literal floats. --- Cython/Compiler/ExprNodes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index f4c50849..e183a013 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -885,7 +885,7 @@ class FloatNode(ConstNode): return float(self.value) def calculate_result_code(self): - strval = str(self.value) + strval = repr(float(self.value)) if strval == 'nan': return "(Py_HUGE_VAL * 0)" elif strval == 'inf': @@ -1042,9 +1042,9 @@ class ImagNode(AtomicNewTempExprNode): def generate_result_code(self, code): code.putln( - "%s = PyComplex_FromDoubles(0.0, %s); %s" % ( + "%s = PyComplex_FromDoubles(0.0, %r); %s" % ( self.result(), - self.value, + float(self.value), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) -- 2.26.2