Writing a CPython extension - calling another sibbling method ?

R.Wieser address at not.available
Mon Nov 18 02:52:07 EST 2019


Hello all,

I'm trying to edit a binary extension to Python, and have a situation where 
I would like to create method which adds a single argument, and than jumps 
to / calls another method.  Like this:

static PyObject *py_proc1(PyObject *self, PyObject *args)
{
....
  Py_RETURN_NONE
}

static PyObject *py_proc2(PyObject *self, PyObject *args)
{
   // call py_proc1 to with "foo" prepended to "args"
}

I have no idea how I should do either the call or the adding of that 
argument (and going to a few examples I've found googeling didn't show me 
the answer either).

Than again, I'm not even sure if the "foo" needs to be prepended, or if that 
"py_proc1" method can receive more than a single "args" argument ...  Like 
this perhaps:

static PyObject *py_proc1(PyObject *self, int MyNewArgument, PyObject *args)
{
....
}

I've also tried to go the C way (just calling, from "py_proc2", a C function 
containing "py_proc1"s code), but I got lots of errors, most of them in the 
realm of the different returns not being of the same type (no idea why it 
doesn't complain about it in the origional "py_proc1" code itself though).

tl;dr:
I could use some examples that show how to work withl PyObject subfunctions.

Regards,
Rudy Wieser

P.s.
Yes, this is related to my earlier questions and problems.




More information about the Python-list mailing list