[PyQt] [PyQT] Segfault when pickling a QByteArray

Phil Thompson phil at riverbankcomputing.com
Tue Dec 20 13:41:35 GMT 2011


On Tue, 20 Dec 2011 15:30:48 +0200, cantabile <cantabile.desu at gmail.com>
wrote:
> On 12/19/2011 05:53 PM, Phil Thompson wrote:
>> On Mon, 19 Dec 2011 14:49:18 +0200, cantabile<cantabile.desu at gmail.com>
>> wrote:
>>> Hello,
>>>
>>> The sample code is attached. It segfaults at pickle.dump().
>>> However, pickling something like QByteArray("asdf") works fine.
>>> This is with python 3. The exact same code works with python 2
>>> (same pyqt, sip and qt versions).
>>>
>>> A backtrace is also attached. I see a lot of "<optimized out>" in the
>>> backtrace - should I recompile python and/or sip with -O0 or something
>>> like that?
>>>
>>> Python 3 version: 3.2.2
>>> Python 2 version: 2.7.2
>>> Pyqt     version: 4.8.6
>>> Sip      version: 4.13
>>> Qt       version: 4.7.4
>>>
>>> Operating system: 64 bit arch linux.
>>
>> Hmm, one SIP bug, one PyQt bug. Fixed in tonight's snapshots.
>>
>> Thanks,
>> Phil
> That was fast. Thank you. :)
> 
> The segfault is gone. However, the sample I attached still doesn't work
> as is with python 3. I get this error:
> ~~~~~~~~~~~~~~~~~~~~
>      pickle.dump(tmp_bytearray, f)
> UnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position 0: 
> invalid start byte
> ~~~~~~~~~~~~~~~~~~~~

You get that if you fix the SIP bug but don't fix the PyQt bug.

> Changing that line to:
> pickle.dump(bytes(tmp_bytearray), f)
> makes it all work.
> 
> I should mention that I did not use the snapshots, but instead I patched
> sip 4.13 with changeset 29ec1c523114 and pyqt 4.8.6 with the attached
> diff. I hope this error is not due to cherrypicking those changes.

...or you didn't apply them properly.

Phil


More information about the PyQt mailing list