1

My PyFLoat_ParseTuple call always return false, with correct call from python side.

I am working on wrapping my C++ for Python and using python extension. I had a successful project, and generating the current one based on that.
I always had a crash in my python run, and during the investigation I reduced my code to the following minim code to repeat it.

If I change both C++/Python side to non-arg call, it works as expected. But the "Parse error" is always printed when I passed in args.

C++:

static PyObject *myfunc(PyObject *self, PyObject *args)
{
    float v[6];
    if (!PyArg_ParseTuple(args, "ffffff", v,v+1,v+2,v+3,v+4,v+5));
    { 
                //I can alway see this prited.
        cerr<<"Parse error\n";
        return NULL;
    }
        return PyString_FromFormat("No error!\n");
}

Python:

print func(0.1,0.2,0.3,0.4,0.5,0.6)

1 Answer 1

1

a very simple typo:

if (!PyArg_ParseTuple(args, "ffffff", v,v+1,v+2,v+3,v+4,v+5));

- see the semicolon ; at the end of if?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.