[PyQt] Re: ConvertToSubClass problem

Phil Thompson phil at riverbankcomputing.com
Tue Nov 18 19:15:13 GMT 2008


On Tue, 18 Nov 2008 13:16:15 +0000 (UTC), MatteoBertini
<naufraghi at develer.com> wrote:
> Giovanni Bajo <rasky <at> develer.com> writes:
> 
>> > > &&  !PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)subtype)
>> > 
>> > && PyType_IsSubtype((PyTypeObject *)subtype, (PyTypeObject *)type)
>> > 
>> 
>> By inverting the arguments, you're effectively inverting the resulting
>> truth-value and thus obtaining the same effect that you obtain by
>> commenting it.
> 
> I have removed the ! in front too.
> 
> The problem can be related with the question "IsSubtype(a, a) == True?"
> (not investigated)

I think you are right. Try changing the line to...

if (subtype != NULL &&
    (type == subtype ||
     !PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)subtype)))

...I think.

Phil


More information about the PyQt mailing list