After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 561826 - TextBuffer serialize default function segfault
TextBuffer serialize default function segfault
Status: RESOLVED FIXED
Product: pygtk
Classification: Bindings
Component: gtk
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-21 16:00 UTC by Lionel Dricot
Modified: 2010-12-23 21:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
textbuffer example (1.40 KB, application/force-download)
2010-12-23 21:30 UTC, Dieter Verfaillie
Details

Description Lionel Dricot 2008-11-21 16:00:34 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)
Comment 1 Lionel Dricot 2008-11-21 16:05:46 UTC
might be related to #561827
Comment 2 Paul Pogonyshev 2008-12-03 19:47:15 UTC
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):
  • File "/home/paul/test/test.py", line 12 in <module>
    buffer.deserialize (buffer, format, buffer.get_end_iter (), serialized)
glib.GError: No deserialize function found for format application/x-gtk-text-buffer-rich-text

Off to studying how serialization is supposed to work...
Comment 3 Dieter Verfaillie 2010-12-23 21:30:41 UTC
Created attachment 176971 [details]
textbuffer example
Comment 4 Dieter Verfaillie 2010-12-23 21:32:13 UTC
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)...