Fix SF bug# 676155, RuntimeWarning with tp_compare

Check return value of PyLong_AsDouble(), it can return an error.
This commit is contained in:
Neal Norwitz 2003-01-28 19:21:24 +00:00
parent 54fb192508
commit abcb0c03ad
4 changed files with 13 additions and 3 deletions

View file

@ -629,7 +629,10 @@ float_coerce(PyObject **pv, PyObject **pw)
return 0;
}
else if (PyLong_Check(*pw)) {
*pw = PyFloat_FromDouble(PyLong_AsDouble(*pw));
double x = PyLong_AsDouble(*pw);
if (x == -1.0 && PyErr_Occurred())
return -1;
*pw = PyFloat_FromDouble(x);
Py_INCREF(*pv);
return 0;
}