From: Neil Schemenauer Date: Mon, 18 Nov 2002 16:06:21 +0000 (+0000) Subject: Improve exception message raised by PyFloat_AsDouble if the object does not X-Git-Tag: v2.3c1~3373 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c77e90804bbce12ca0e724b4138b9911f7b712e;p=thirdparty%2FPython%2Fcpython.git Improve exception message raised by PyFloat_AsDouble if the object does not have a nb_float slot. This matches what PyInt_AsLong does. --- diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 36e861e0a9e5..924b31293b0f 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -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;