Python C interface PyArg_ParseTuple failing
===

I have a Python module written in C with a number of functions exposed.  One of them has a Python definition of:

    def SetPowerSupply(voltage, current, supply):

where voltage = float, current = float, and supply = int. On the C side, I have this:

    float voltage, current;
    int supply;

    if (!PyArg_ParseTuple(args, "ffi", &voltage, &current, &supply))
    {
        // Failed to parse
        // ...
    }

One of my scripters has a script wherein this function fails to parse the arguments, complaining that an integer is expected. So far as I can tell, an integer is in fact being passed in since if in the error branch I do this:


    PyObject *num = PyNumber_Float(PyTuple_GetItem(args, 0));
    voltage = PyFloat_AsDouble(num);
    Py_XDECREF(num);
			
    num = PyNumber_Float(PyTuple_GetItem(args, 1));
    current = PyFloat_AsDouble(num);
    Py_XDECREF(num);

    num = PyNumber_Int(PyTuple_GetItem(args, 2));
    supply = PyLong_AsLong(num);
    Py_XDECREF(num);

... then everything works as expected. Other script running through this module do not exhibit this behaviour, and I can see no differences.  Both of them call the function the same:

    SetPowerSupply(37.5, 0.5, 1)
    SetPowerSupply(0, 0, 1)

In the offending script I can do something like this:

Any ideas???

Thank you.