[PyQt] QTextBlockUserData forgotten in SIP 4.14.3, bug?

Wilbert Berendsen wbsoft at xs4all.nl
Mon Mar 11 10:13:15 GMT 2013


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?


Wilbert Berendsen


-- 
Wilbert Berendsen
(http://www.wilbertberendsen.nl)



More information about the PyQt mailing list