[Python-Dev] GC and ExtensionClass

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Mon, 14 May 2001 21:40:21 +0200


> Okay, so I'm completed confused now.  I extended the definition of
> ECTypeType to include this after the doc string slot:
> 
>       (traverseproc)0,              /* tp_traverse */
>       (inquiry)0,                   /* tp_clear */
>       (richcmpfunc)0,               /* rich comparisons */
>       0L,                           /* weak reference enabler */
> 
>     #ifdef COUNT_ALLOCS
>       /* these must be last */
>       0,                            /* tp_alloc */
>       0,                            /* tp_free */
>       0,                            /* tp_maxalloc */
>       (struct _typeobject *)0,      /* tp_next */
>     #endif

Why did you do that? ECTypeType has the right data type
(PyTypeObject). It is the instances of PyExtensionClass that are
troubling

> When I looked at the definition of ECType, after the doc string I saw
> 
>       METHOD_CHAIN(ExtensionClass_methods)
> 
> as Martin indicated.  I can't simply insert the same zeroes at the end of
> the ECType def'n as I did at the end of the ECTypeType definition.  

Of course not. ECType is of type PyExtensionClass, not of type
PyTypeObject. Those are similar, but not equal.

> Where does this METHOD_CHAIN thing go?  I looked at the def'n of
> struct _typeobject in Include/object.h but didn't see a slot that
> looked suitable.

Just have a look at ExtensionClass.h instead.

> FWIW, when I build Python and PyGtk with Py_DEBUG defined as Neil suggested,
> I get 
> 
>     Fatal Python error: UNREF invalid object
> 
> when I run my failing script.  This is with and without making any changes
> to ECType or ECTypeType.

BTW, what version of PyGtk did you try to compile? I've tried the
0.7.0-dont-use, and it can run examples/testgtk without major problems
(the example did need some updates, since it is apparently outdated).
My Gtk version was 1.2, on Linux.

In any case, I think you need to analyse this in a debugger.

Regards,
Martin