GNOME Bugzilla – Bug 561826
TextBuffer serialize default function segfault
Last modified: 2010-12-23 21:32:13 UTC
Take a gtk.textbuffer with some text in it and try to serialize it with the default (and only) serialize function : buff = self.textview.get_buffer() format = 'application/x-gtk-text-buffer-rich-text' serial = buff.serialize(buff,format,buff.get_start_iter(),buff.get_end_iter()) f = open('serial.txt','w') f.write(serial) f.close Then try to import : f = open('serial.txt','r') deserial = f.read() f.close() result = buff.deserialize(buff, format, buff.get_end_iter(), deserial) This will result in a segfault which should never happen. (If it fails, it should only return False)
might be related to #561827
First of all, I committed a fix for the segfault in PyGObject. If you can, please test SVN revision 976. Now I get this: Traceback (most recent call last):
+ Trace 210456
buffer.deserialize (buffer, format, buffer.get_end_iter (), serialized)
Off to studying how serialization is supposed to work...
Created attachment 176971 [details] textbuffer example
Tested serializing/deserializing with pygtk-2.22.0 and the fix Paul did (see comment 2) works correctly. See the attached textbuffer.py for a working example. About the original example from the bug report, the serialized data should probably be written to and read from a file opened in binary mode as it contains null characters (and maybe other control characters)...