On 12/19/2011 05:53 PM, Phil Thompson wrote:
On Mon, 19 Dec 2011 14:49:18 +0200, cantabile<cantabile.d...@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
~~~~~~~~~~~~~~~~~~~~
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.
--
cantabile
"Jayne is a girl's name." -- River
diff -ru PyQt-x11-gpl-4.8.6/sip/QtCore/qbytearray.sip PyQt-x11-gpl-snapshot-4.9-189b39e6b6c3/sip/QtCore/qbytearray.sip
--- PyQt-x11-gpl-4.8.6/sip/QtCore/qbytearray.sip 2011-10-24 14:30:47.000000000 +0300
+++ PyQt-x11-gpl-snapshot-4.9-189b39e6b6c3/sip/QtCore/qbytearray.sip 2011-12-20 04:43:33.000000000 +0200
@@ -1,4 +1,4 @@
-// qbytearray.sip generated by MetaSIP on Mon Oct 24 12:30:43 2011
+// qbytearray.sip generated by MetaSIP on Tue Dec 20 02:43:32 2011
//
// This file is part of the QtCore Python extension module.
//
@@ -174,7 +174,11 @@
%End
%PickleCode
+ #if PY_MAJOR_VERSION >= 3
+ sipRes = Py_BuildValue((char *)"(y#)", sipCpp->data(), sipCpp->size());
+ #else
sipRes = Py_BuildValue((char *)"(s#)", sipCpp->data(), sipCpp->size());
+ #endif
%End
public:
@@ -395,6 +399,9 @@
%If (Qt_4_5_0 -)
QByteArray repeated(int times) const;
%End
+%If (Qt_4_8_0 -)
+ void swap(QByteArray &other);
+%End
};
bool operator==(const QByteArray &a1, const QByteArray &a2);
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt