mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Fix SF bug# 676155, RuntimeWarning with tp_compare
Check return value of PyLong_AsDouble(), it can return an error.
This commit is contained in:
parent
54fb192508
commit
abcb0c03ad
4 changed files with 13 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue