GNOME Bugzilla – Bug 318874
gdk_bitmap_create_from_data Exception with Python2.4.2
Last modified: 2007-05-15 09:42:14 UTC
gibbs@t41:~$ python Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import array, gtk >>> gtk.gdk.bitmap_create_from_data(None, array.array('B', ... [0x00, 0x1f, 0x11, 0x1f, 0x00]).tostring(), 5, 5) Traceback (most recent call last):
+ Trace 63540
bytes, not str
I was able to make it work by making the following changes to the generated gdk.c file: 10609d10608 < int length; 10611c10610 < if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os#ii:bitmap_create_from_data", kwlist, &py_drawable, &data, &length, &width, &height)) --- > if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Osii:bitmap_create_from_data", kwlist, &py_drawable, &data, &width, &height)) According to the Python extension API, it is necessary to use the "s#" format when passing binary data that may contain NULL bytes. see http://python.org/doc/2.4.2/api/arg-parsing.html I am not sure how this change would translate into the .defs or .override files.
Checking in ChangeLog; /cvs/gnome/gnome-python/pygtk/ChangeLog,v <-- ChangeLog new revision: 1.1324; previous revision: 1.1323 done Checking in gtk/gdk.defs; /cvs/gnome/gnome-python/pygtk/gtk/gdk.defs,v <-- gdk.defs new revision: 1.91; previous revision: 1.90 done Checking in tests/Makefile.am; /cvs/gnome/gnome-python/pygtk/tests/Makefile.am,v <-- Makefile.am new revision: 1.23; previous revision: 1.22 done RCS file: /cvs/gnome/gnome-python/pygtk/tests/test_gdk.py,v done Checking in tests/test_gdk.py; /cvs/gnome/gnome-python/pygtk/tests/test_gdk.py,v <-- test_gdk.py initial revision: 1.1 done
Note this bug was present for pygtk-2.8.[12] Unfortunately ubuntu breezy was released with pygtk-2.8.1 Also this bug was fixed previously, the original bug being 103616