[PyQt] Possible bug in SIP
Phil Thompson
phil at riverbankcomputing.com
Mon Jul 11 16:31:06 BST 2011
On Mon, 11 Jul 2011 12:12:11 +0100, "Tony Lynch" <tlynch at xype.com> wrote:
> Hi Phil
>
>
>
> I'm using SIP to wrap a large C++ library
I wonder which one that is... :)
> and am very impressed with the
> results so far - you've got an annotation for most of the use cases I'm
> interested in. However, I think I've found a bug. I've copied in below
> my own 'description to self' of the problem, if it is not sufficient for
> you to see the problem then I'll knock up a test case (let me know).
>
>
>
> When the wrapper for a class or one of its super classes indicates
> 'virtual' for a method, a wrapper class is created in SIP called e.g.
> sipIwBrep, that checks if the python instance has an override method for
> the virtual call. If not then it calls what it thinks is the correct
> superclass call. However, it's idea of the correct superclass call (in
> this case the superclass being IwBrep) is actually calculated from the
> wrapper declarations and it effectively finds the nearest superclass
> where the relevant function is wrapped. In the case of this bug,
> IwObject was the first superclass to have IsKindOf in the .sip file, so
> sipIwBrep was incorrectly calling IwObject::IsKindOf instead of
> IwBrep::IsKindOf.
>
>
>
> I cannot see any reason why the SIP-produced subclass does not always
> call the method on the immediate superclass (i.e. the wrapped class, in
> this case IwBrep).
>
>
>
> I hope the above makes sense,
>
> Regards
>
> Tony
The honest reason is, all those years ago when I first wrote the code, I
didn't realise that C++ would do the right thing when calling a
non-existent explicit super-class method. So it's not a bug, it's a
conscious decision to do it that way. "Fixing" it would be a change of
behaviour which I'm not willing to do for SIP4 - happy to change it for
SIP5 though.
Phil
More information about the PyQt
mailing list