[capi-sig] Getting Numbers in C
Hrvoje Niksic
hniksic at xemacs.org
Fri Jul 13 13:27:59 CEST 2007
> double PyNumber_AsDouble(PyObject * value)
> {
> if (PyFloat_Check(value) || PyInt_Check(value)) {
> return PyFloat_AsDouble(value);
> } else {
> PyObject *pyfloat;
> double d;
>
> pyfloat = PyNumber_Float(value);
> d = PyNumber_AsDouble(pyfloat);
I assume this should be PyFloat_AsDouble?
> Py_XDECREF(pyfloat);
> return d;
> }
> }
What happens if PyNumber_Float raises an exception? As far as I can
tell, PyNumber_AsDouble will result in a "bad argument" exception
being raised and will return -1, losing track of the original
exception in the process.
Come to think of it, error checking problems could very well be the
reason why the API doesn't provide a PyNumber_AsDouble.
More information about the capi-sig
mailing list