Commit 2c77e908 authored by Neil Schemenauer's avatar Neil Schemenauer

Improve exception message raised by PyFloat_AsDouble if the object does not

have a nb_float slot.  This matches what PyInt_AsLong does.
parent 26db5874
......@@ -202,12 +202,16 @@ PyFloat_AsDouble(PyObject *op)
if (op && PyFloat_Check(op))
return PyFloat_AS_DOUBLE((PyFloatObject*) op);
if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL ||
nb->nb_float == NULL) {
if (op == NULL) {
PyErr_BadArgument();
return -1;
}
if ((nb = op->ob_type->tp_as_number) == NULL || nb->nb_float == NULL) {
PyErr_SetString(PyExc_TypeError, "a float is required");
return -1;
}
fo = (PyFloatObject*) (*nb->nb_float) (op);
if (fo == NULL)
return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment