@@ -305,32 +305,20 @@ convert_to_double(PyObject **v, double *dbl)
305305}
306306
307307static PyObject *
308- float_str_or_repr (PyFloatObject * v , int precision , char format_code )
308+ float_repr (PyFloatObject * v )
309309{
310310 PyObject * result ;
311311 char * buf = PyOS_double_to_string (PyFloat_AS_DOUBLE (v ),
312- format_code , precision ,
312+ 'r' , 0 ,
313313 Py_DTSF_ADD_DOT_0 ,
314314 NULL );
315315 if (!buf )
316- return PyErr_NoMemory ();
316+ return PyErr_NoMemory ();
317317 result = PyUnicode_FromString (buf );
318318 PyMem_Free (buf );
319319 return result ;
320320}
321321
322- static PyObject *
323- float_repr (PyFloatObject * v )
324- {
325- return float_str_or_repr (v , 0 , 'r' );
326- }
327-
328- static PyObject *
329- float_str (PyFloatObject * v )
330- {
331- return float_str_or_repr (v , PyFloat_STR_PRECISION , 'g' );
332- }
333-
334322/* Comparison is pretty much a nightmare. When comparing float to float,
335323 * we do it as straightforwardly (and long-windedly) as conceivable, so
336324 * that, e.g., Python x == y delivers the same result as the platform
@@ -1169,7 +1157,7 @@ float_hex(PyObject *v)
11691157 CONVERT_TO_DOUBLE (v , x );
11701158
11711159 if (Py_IS_NAN (x ) || Py_IS_INFINITY (x ))
1172- return float_str ((PyFloatObject * )v );
1160+ return float_repr ((PyFloatObject * )v );
11731161
11741162 if (x == 0.0 ) {
11751163 if (copysign (1.0 , x ) == -1.0 )
@@ -1873,7 +1861,7 @@ PyTypeObject PyFloat_Type = {
18731861 0 , /* tp_as_mapping */
18741862 (hashfunc )float_hash , /* tp_hash */
18751863 0 , /* tp_call */
1876- (reprfunc )float_str , /* tp_str */
1864+ (reprfunc )float_repr , /* tp_str */
18771865 PyObject_GenericGetAttr , /* tp_getattro */
18781866 0 , /* tp_setattro */
18791867 0 , /* tp_as_buffer */
0 commit comments