From: Robert Bradshaw Date: Tue, 20 Jan 2009 01:48:38 +0000 (-0800) Subject: Must use repr() not str() for literal floats. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5da90229e34b6f7a646cd06afa5b875dd9155a78;p=cython.git Must use repr() not str() for literal floats. --- 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())