[PyKDE] False Attribute Errors
Phil Thompson
phil at riverbankcomputing.co.uk
Mon Feb 7 07:36:37 GMT 2005
On Monday 07 February 2005 4:02 am, bdw wrote:
> After I installed the latest snapshots recently, I started getting what
> seem to be false Attribute Errors. The problem affects Qt objects which
> I have added properties to like this:
>
> class MyCustomWidget(QWidget):
> def __init__(self, parent):
> QWidget.__init__(self, parent)
> self.newProperty = 1
>
> If I insert blocks of asserts like this at various places,
>
> assert hasattr(mywidget,'className')
> assert hasattr(mywidget,'geometry')
> assert hasattr(mywidget,'newProperty')
>
> only the last one ever gives an Attribute Error. That is, the QObject
> and QWidget attributes are okay, but not the Python one. The crazy
> thing is, it doesn't happen all the time or even in the same sections
> of code - so I can't really give any specific samples.
>
> The problem occurs with the following set up:
>
> sip-20050129, pyqt-20050129, qscintilla-20050122
> python-2.4, qt-3.2.3
>
> I also re-compiled everything using the 20050204 sip snapshot, but it
> didn't change anything.
>
> Has anyone else seen this kind of thing? Any help at all would be
> welcome as this has really got me stumped!
I think it's a SIP bug - you'll probably find that the type of mywidget is not
what you expect when the AttributeError is raised. It's the one thing that's
holding up the release of SIP 4.2.
Phil
More information about the PyQt
mailing list