[capi-sig] Keyword creation in a module function

Robert Steckroth robertsteckroth at gmail.com
Fri Nov 9 04:54:24 CET 2012


Well, turns out that while the keyword dictionary thing is complex, my
problem was elsewhere.
Is it possible that the documentation is wrong?

The capital "S" in the docs state this ->
 S (object) [PyObject *]
Same as O.
here http://docs.python.org/2/c-api/arg.html?highlight=keyword#Py_BuildValue
But "S" it has string checking properties as opposed to "O".

E.g.
"if ( ! PyArg_ParseTupleAndKeywords(args, kwds, "|OSllS"...    !=    "if (
! PyArg_ParseTupleAndKeywords(args, kwds, "|OOllO"...


Anyway, got my thing figured out :)


On Thu, Nov 8, 2012 at 6:09 PM, Robert Steckroth
<robertsteckroth at gmail.com>wrote:

> Hey Gang, I have come across the need to pass both keywords and arguments
> from one function to another. The keywords are passing just fine with a
> PyObjectCall command. However, if the user does not specify any keywords at
> the interpretor, the command will seg-fault.
> The docs state that keywords argument can be NULL, but this does not work
> with NULL set objects.
> How do I build a keywords dictionary which can function correctly if there
> are none to start with or if the user defined some? I am thinking it can
> be done with a PyDict() like command?
>
> The below snippet is the scenario I am trying to achieve -->
>
> if ( kwds ) {
>        self->c_surface = PyObject_Call((PyObject *) &PyMyObject_Type,
> object_args, kwds); }
> else { self->c_surface = PyObject_Call((PyObject *) &PyMyObject_Type,
> object_args, NULL); }
>
>
>
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> surgemcgee.com
> Django_Teamplate3d
>



-- 
Bust0ut, Surgemcgee: Systems Engineer ---
surgemcgee.com
Django_Teamplate3d


More information about the capi-sig mailing list