diff -r fff0c783d3db Objects/floatobject.c --- a/Objects/floatobject.c Wed May 11 22:25:31 2016 +0300 +++ b/Objects/floatobject.c Thu May 12 09:44:02 2016 +0300 @@ -1195,7 +1195,7 @@ Return a hexadecimal representation of a static PyObject * float_fromhex(PyObject *cls, PyObject *arg) { - PyObject *result_as_float, *result; + PyObject *result; double x; long exp, top_exp, lsb, key_digit; char *s, *coeff_start, *s_store, *coeff_end, *exp_start, *s_end; @@ -1410,11 +1410,10 @@ float_fromhex(PyObject *cls, PyObject *a s++; if (s != s_end) goto parse_error; - result_as_float = Py_BuildValue("(d)", negate ? -x : x); - if (result_as_float == NULL) - return NULL; - result = PyObject_CallObject(cls, result_as_float); - Py_DECREF(result_as_float); + result = PyFloat_FromDouble(negate ? -x : x); + if (cls != (PyObject *)&PyFloat_Type && result != NULL) { + Py_SETREF(result, PyObject_CallFunctionObjArgs(cls, result)); + } return result; overflow_error: