[PyKDE] Bug with super and QObject

Phil Thompson phil at riverbankcomputing.co.uk
Tue Apr 12 16:59:05 BST 2005


> Hello:
>
>>>> from qt import *
>>>> class A(QObject):
> ...     pass
> ...
>>>> a=A()
>>>> super(A, a).emit("foo")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'super' object has no attribute 'emit'
>>>> super(A, a).emit(PYSIGNAL("foo"), ())
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'super' object has no attribute 'emit'
>
> Why is super broken?

It's to do with how SIP implements lazy methods (to save on memory and
startup time). super seems to be bypassing the hook (maybe it uses
tp_getattro rather than tp_getattr). Should be fixable - I'll have a look.

A (not very satisfactory) work around is to make sure the attribute is in
the instance dictionary before super looks for it, ie. insert this before
the call to super...

a.emit

Phil




More information about the PyQt mailing list