[pygtk] TypeError: multiple bases have instance lay-out conflict

Josh Green josh at resonance.org
Mon Jul 31 03:03:10 WST 2006


Replying to myself since I figured out what the problem is.  It appears
the second crash bug was triggered by another bug in PyGTK 2.8.6.  The
"TypeError: multiple bases have instance lay-out conflict" was indeed
occurring because the SwamiguiRoot object type had not be registered.
The reason was that the gtk module was failing to import with the
following exception:

Traceback (most recent call last):
  File "/home/josh/local/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 36, in ?
    if sys.argv:
AttributeError: 'module' object has no attribute 'argv'

The sys.argv variable does not exist when Python is being used as an
embedded interpreter (which is the case with Swami).

Filed under the following bugs:
http://bugzilla.gnome.org/show_bug.cgi?id=349326
http://bugzilla.gnome.org/show_bug.cgi?id=349328

Best regards,
	Josh Green


On Sun, 2006-07-30 at 15:22 +0200, Josh Green wrote:
> 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
> 
> 
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> 



More information about the pygtk mailing list