GTK segfault with GTK3 and mpl_toolkits #1813

Merged
merged 2 commits into from May 28, 2013

Projects

None yet

3 participants

@mdboom
Contributor
mdboom commented May 20, 2013

Something goes wrong when using a GTK3 backend and the mpl_toolkits. See this very minimal testcase:

>>> from gi.repository import Gtk
>>> import mpl_toolkits.axisartist
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: specified class size for type `PyGtkGenericCellRenderer' is smaller than the parent type's `GtkCellRenderer' class size
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentatiefout (geheugendump gemaakt)

Most likely, something imports the old GTK2 bindings, run following for the same error:

>>> from gi.repository import Gtk
>>> import gtk

Grepping the sourcecode gives mpl_toolkits/gtktools.py where it is used, but I can't even find where it is imported.

Owner
mdboom commented May 20, 2013

This looks as if you do not have the development files for Gtk3 installed. Would you mind testing the attached patch? It should give you an error message to this effect.

@efiring efiring and 1 other commented on an outdated diff May 25, 2013
lib/matplotlib/backends/backend_gtk3.py
@@ -4,6 +4,16 @@
def fn_name(): return sys._getframe(1).f_code.co_name
try:
+ import gi
+except ImportError:
+ raise ImportError("Gtk3 backend requires pygobject to be installed.")
+
+try:
+ gi.require_version("Gtk", "3.0")
+except ValueError:
+ raise ImportError("Gtk3 backend gtk3 development files to be installed.")
efiring
efiring May 25, 2013 Owner

Missing word: "requires".
Also, this has me puzzled, because I can run the gtk3agg backend on ubuntu Precise, but I don't have the libgtk-3-dev package installed.

mdboom
mdboom May 28, 2013 Owner

It seems things are packaged somewhat differently on Debian/Ubuntu than on Fedora. I think on Ubuntu, the required package is: gir1.2-gtk3.0 https://launchpad.net/ubuntu/precise/+package/gir1.2-gtk-3.0

Since we don't really know what distro the user will be using, I'm inclined to change this to:

"The Gtk3 backend requires that the GObject introspection bindings for Gtk 3 are installed."

That should give a user enough to Google something by.

@mdboom mdboom merged commit dd38945 into matplotlib:master May 28, 2013
@mdboom mdboom deleted the mdboom:gtk3-version-check branch Aug 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment