[PyQt] Not getting it re sip.voidptr

Phil Thompson phil at riverbankcomputing.com
Sun Nov 11 11:57:28 GMT 2012


On Sun, 04 Nov 2012 18:53:18 +0000, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> On Sun, 4 Nov 2012 09:34:32 -0800, David Cortesi <davecortesi at gmail.com>
> wrote:
>>>> When I try assignment,
>>>>     vptr[1] = 0x00
>>>> I get the message,
>>>>     TypeError: 'int' does not have the buffer interface
>> 
>>> I can't reproduce this - can you send a short, complete test that
>>> demonstrates the problem.
>> 
>> Here you go: Ubuntu 12.10, PyQt4 4.9.3-4
>> 
>> $ python
>> Python 2.7.3 (default, Sep 26 2012, 21:53:58)
>> [GCC 4.7.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> from PyQt4 import QtCore, QtGui
>>>>> img = QtGui.QImage(100,100,QtGui.QImage.Format_ARGB32)
>>>>> img.fill(0xdeadbeef)
>>>>> vptr = img.bits()
>>>>> vptr.setsize(img.byteCount())
>>>>> vptr[0] = 0
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>> TypeError: 'int' does not have the buffer interface
>>>>>
> 
> Fixed in tonight's SIP snapshot - thanks.

I have backed out this fix as it make the behaviour different to
memoryview.

The correct fix is to do this...

    vptr[1] = '\x00'

Phil


More information about the PyQt mailing list