[pygtk] TypeError: multiple bases have instance lay-out conflict
Josh Green
josh at resonance.org
Sun Jul 30 21:22:17 WST 2006
I'm a developer for a GObject/GTK based project called Swami which makes
use of PyGTK to create its Python bindings. I'm experiencing a crash
with Swami when using PyGTK 2.8.6 which does not occur when using PyGTK
2.8.2. I hope someone here can help me fix this problem. I suspect a
PyGTK bug for the crash, but as to what is triggering it I'm not sure.
The crash occurs when the following Python code is executed from within
the C code of the GUI:
PyRun_SimpleString ("swamigui.root = swamigui.swamigui_get_root()\n")
This causes:
TypeError: multiple bases have instance lay-out conflict
Segmentation fault (core dumped)
'swamigui' is the Python module name for the Swami GUI. The
swamigui_get_root() function is written as an override method, and its
contents are this:
override swamigui_get_root kwargs
static PyObject *
_wrap_swamigui_get_root (PyObject *self, PyObject *args,
PyObject *kwargs)
{
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)swamigui_root);
}
swamigui_root is a global pointer to an object of type SwamiguiRoot
(inheritance: GObject->SwamiLock->SwamiRoot->SwamiguiRoot).
The "TypeError: multiple ..." is printed from gobject/pygobject.c:624
(PyGtk 2.8.6) from this code in pygobject_new_with_interfaces():
type = (PyTypeObject*)PyObject_CallFunction((PyObject*)&PyType_Type, "sNN", type_name, bases, dict);
g_free(type_name);
if (type == NULL) {
PyErr_Print(); <---- Here the "TypeError: .."
pyg_gil_state_release(state);
return NULL;
}
The crash occurs at pygobject.c:725:
722 PyTypeObject *tp = pygobject_lookup_class(G_OBJECT_TYPE(obj));
723 /* need to bump type refcount if created with
724 pygobject_new_with_interfaces(). fixes bug #141042 */
725 if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE)
726 Py_INCREF(tp);
NULL is returned from pygobject_lookup_class() in response to the
TypeError, and then tp is accessed (although it is NULL).
I think the crash is a PyGTK bug (return of pygobject_lookup_class()
should be checked), but I'm not sure why the TypeError is occurring
(which is triggering this bug). I fixed a problem with identical output
and resulting crash previously, which was related to a type not being
bound properly as a PyGTK GObject. I've checked the python binding defs
files for the SwamiguiRoot type though and all seems in order. Running
this same bit of Python code in a python interpreter works fine, its
only when it is executed from within the C code (although I may be
overlooking something else). Any help would be greatly appreciated.
Best regards,
Josh Green
More information about the pygtk
mailing list