[Python-Dev] GC and ExtensionClass (original) (raw)

skip@pobox.com (Skip Montanaro) skip@pobox.com (Skip Montanaro)
Mon, 14 May 2001 10:54:54 -0500


Martin> That *should* work, except that it also has its 'methods' field
Martin> where tp_traverse would go, and its class_flags field where
Martin> tp_clear would go.

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

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. 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.

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.

Skip