[PyQt] SIP support for keyword arguments in __call__ ?
Ravi kumar
ravi.kumar.039 at gmail.com
Mon Mar 8 18:17:27 GMT 2010
On Mon, Mar 8, 2010 at 2:42 PM, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> On Mon, 8 Mar 2010 08:43:31 +0530, Ravi kumar <ravi.kumar.039 at gmail.com>
> wrote:
>> Hello
>>
>> I was trying to pass keyword arguments to operator ()
>> of a class from python. The class was extended using SIP.
>> The name of the class is Signal (it is not Qt's signal).
>>
>> At first i tried /NoArgParser/ on __call__ but it was
>> not producing the code i wanted. So, just to give it a try,
>> i manually removed all the argument parsing code from the
>> generated function, and added another PyObject* to the
>> argument list to slot_Signal___call__. But soon i realized
>> that anything done on it results in segmentation fault, which
>> means nothing is being passed to it.
>>
>> Then i investigated the source code of sip. In siplib/siplib.c
>> i found this function :
>> static PyObject *slot_call (PyObject *self, PyObject *args, PyObject
>> *kwargs)
>>
>> With trivial changes to this function, and recompiling sip
>> the keyword arguments were working fine, though still code
>> generated by sip needed to be modified.
>>
>> But the main question i wanted to ask, is that i found a note
>> written in siplib.c just above that slot_call function :
>>
>> "The type call slot. Note that keyword arguments aren't supported".
>>
>> Was there any specific reason to avoid support for keyword
>> arguments ? If not, then i am willing to write a patch for
>> code generator (sipgen) so that it honors /NoArgParser/ and provides
>> an additional argument for keywords, should i go ahead ?
>
> You can try. I think you will have to introduce a new slot type so that you
> don't break backwards binary compatibility.
>
> Phil
>
Ok, i give it a try now.
Thanks
More information about the PyQt
mailing list