diff Objects/floatobject.c @ 27485:36f71fef5b10 2.2

backport: Fix SF bug# 676155, RuntimeWarning with tp_compare Check return value of PyLong_AsDouble(), it can return an error.
author Neal Norwitz <nnorwitz@gmail.com>
date Tue, 28 Jan 2003 19:40:35 +0000
parents f38bdb2fcae0
children
line wrap: on
line diff
--- a/Objects/floatobject.c	Sat Jan 25 03:48:12 2003 +0000
+++ b/Objects/floatobject.c	Tue Jan 28 19:40:35 2003 +0000
@@ -625,7 +625,10 @@
 		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;
 	}