summaryrefslogtreecommitdiffstats
path: root/Objects/floatobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r--Objects/floatobject.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index b17f7be..48d29d7 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -281,6 +281,7 @@ format_float(char *buf, size_t buflen, PyFloatObject *v, int precision)
format_double(buf, buflen, PyFloat_AS_DOUBLE(v), precision);
}
+#ifdef Py_BROKEN_REPR
/* The following function is based on Tcl_PrintDouble,
* from tclUtil.c.
*/
@@ -382,6 +383,8 @@ format_float_repr(char *buf, PyFloatObject *v)
format_double_repr(buf, PyFloat_AS_DOUBLE(v));
}
+#endif /* Py_BROKEN_REPR */
+
/* Macro and helper that convert PyObject obj to a C double and store
the value in dbl. If conversion to double raises an exception, obj is
set to NULL, and the function invoking this macro returns NULL. If
@@ -434,8 +437,14 @@ convert_to_double(PyObject **v, double *dbl)
static PyObject *
float_repr(PyFloatObject *v)
{
+#ifdef Py_BROKEN_REPR
char buf[30];
format_float_repr(buf, v);
+#else
+ char buf[100];
+ format_float(buf, sizeof(buf), v, PREC_REPR);
+#endif
+
return PyUnicode_FromString(buf);
}
@@ -1327,9 +1336,11 @@ _PyFloat_Init(void)
double_format = detected_double_format;
float_format = detected_float_format;
-
+
+#ifdef Py_BROKEN_REPR
/* Initialize floating point repr */
_PyFloat_DigitsInit();
+#endif
}
void