summaryrefslogtreecommitdiffstats
path: root/Objects/floatobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-01-28 19:21:24 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-01-28 19:21:24 (GMT)
commitabcb0c03ade3cee52b71362f57b16af3e00c743b (patch)
treea4afc16116d2e0d08a0ea162932cb635b550bde0 /Objects/floatobject.c
parent54fb192508130fa17df5b252c63d125218907035 (diff)
downloadcpython-abcb0c03ade3cee52b71362f57b16af3e00c743b.zip
cpython-abcb0c03ade3cee52b71362f57b16af3e00c743b.tar.gz
cpython-abcb0c03ade3cee52b71362f57b16af3e00c743b.tar.bz2
Fix SF bug# 676155, RuntimeWarning with tp_compare
Check return value of PyLong_AsDouble(), it can return an error.
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r--Objects/floatobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index cd28349..09406e4 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -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;
}