diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2002-11-18 16:06:21 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2002-11-18 16:06:21 (GMT) |
commit | 2c77e90804bbce12ca0e724b4138b9911f7b712e (patch) | |
tree | eda39e6245df23ad44412d7f6d38f83622d849d1 /Objects/floatobject.c | |
parent | 26db587485ea4e133e8de35aa6ab61f6c51fd993 (diff) | |
download | cpython-2c77e90804bbce12ca0e724b4138b9911f7b712e.zip cpython-2c77e90804bbce12ca0e724b4138b9911f7b712e.tar.gz cpython-2c77e90804bbce12ca0e724b4138b9911f7b712e.tar.bz2 |
Improve exception message raised by PyFloat_AsDouble if the object does not
have a nb_float slot. This matches what PyInt_AsLong does.
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 36e861e..924b312 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; |