[PyQt] sip.cast changes behaviour of == operator?
Phil Thompson
phil at riverbankcomputing.com
Mon Feb 21 22:15:42 GMT 2011
On Mon, 21 Feb 2011 21:30:28 +0100, Andreas Pakulat <apaku at gmx.de> wrote:
> Hi,
>
> still working on the modeltest.py code, picking up one of the older
> threads about it:
>
http://www.opensubscriber.com/message/pyqt@riverbankcomputing.com/10335500.html
>
> As far as I can see the reason for this is the casting done at the start
> of the ModelTest class. It looks like sip.cast changes the behaviour of
> comparing the references in this code:
>
> assert( index.model() == self.model )
>
> index.model() is a QStringListModel instance, self.model is a
> QAbstractItemModel and both have different internal id's.
>
> And it seems like sip.cast creates a new wrapped instance each time,
> simply doing a sip.cast() for the index.model() call does not help.
sip.cast() creates a new Python object (with a different type) for the
same C++ instance. That means that a different C++ implementation of an
operator may be called.
> Is that intentional (I guess so) and is there a way to still get the
> assertion to work as it should?
>
> Andreas
Phil
More information about the PyQt
mailing list