[PyQt] QTextBlockUserData forgotten in SIP 4.14.3, bug?

Phil Thompson phil at riverbankcomputing.com
Mon Mar 11 14:01:21 GMT 2013


On Mon, 11 Mar 2013 11:13:15 +0100, Wilbert Berendsen <wbsoft at xs4all.nl>
wrote:
> Hi,
> 
> It seems sip 4.14.3 forgets QTextUserData objects.
> 
> when I do this (Python 2.7. after importing * from PyQt4.QtCore and
> QtGui):
> 
> This is SIP 4.13.2 (and PyQt 4.9.3):
> 
>>>> doc=QTextDocument()
>>>> print doc.firstBlock().userData()
> None
>>>> data=QTextBlockUserData()
>>>> data.value = 123
>>>> doc.firstBlock().setUserData(data)
>>>> print doc.firstBlock().userData()
> <PyQt4.QtGui.QTextBlockUserData object at 0xb69f880c>
>>>> del data
>>>> # much later we are requesting the data again.....
>>>> print doc.firstBlock().userData()
> <PyQt4.QtGui.QTextBlockUserData object at 0xb69f880c>
>>>> print doc.firstBlock().userData().value
> 123
> 
> Note that in sip 4.13.2 the QTextBlockUserData both times has the same
> object ID.
> 
> Now the same command sequence in SIP 4.14.3 (and PyQt 4.9.6):
> 
>>>> doc=QTextDocument()
>>>> print doc.firstBlock().userData()
> None
>>>> data=QTextBlockUserData()
>>>> data.value = 123
>>>> doc.firstBlock().setUserData(data)
>>>> print doc.firstBlock().userData()
> <PyQt4.QtGui.QTextBlockUserData object at 0xb6a7065c>
>>>> del data
>>>> # much later we are requesting the data again.....
>>>> print doc.firstBlock().userData()
> <PyQt4.QtGui.QTextBlockUserData object at 0xb6a706a4>
>>>> print doc.firstBlock().userData().value
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'QTextBlockUserData' object has no attribute 'value'
> 
> 
> Note that it isn't forgotten that there is a QTextUserData set, but it
> is returned as a different object, without the 'value' attribute that
> was previously set.
> 
> Is this a bug?

It's a PyQt bug - fixed in tonight's snapshot.

Thanks,
Phil


More information about the PyQt mailing list