[SciPy-dev] RE: zeros.c

Chuck Harris Chuck.Harris at sdl.usu.edu
Fri Oct 4 14:41:25 CDT 2002


Hi Travis,

I am glad to see that the reference counting in 
zeros.c got fixed. I had a few more cosmetic fixes
that made the error reporting more useful, namely

double 
scipy_zeros_functions_func(double x, void *params)
{
    scipy_zeros_parameters *myparams = params;
    PyObject *args, *f, *retval=NULL;
    double val;

    args = myparams->args;
    f = myparams->function;
    PyTuple_SetItem(args,0,Py_BuildValue("d",x));
    retval = PyObject_CallObject(f,args); 
    if (PyErr_Occurred()) {
        Py_XDECREF(retval);
        longjmp(myparams->env, 1);
    }
    val = PyFloat_AsDouble(retval);
    if (PyErr_Occurred()) {
        PyErr_SetString(PyExc_RuntimeError,"Could not convert function value to double");
        Py_XDECREF(retval);
        longjmp(myparams->env, 1);
    }
    Py_XDECREF(retval);
    return val;    
}

Chuck



More information about the Scipy-dev mailing list