[Python-Dev] Garbage collector problem
Tim Peters
tim.one@comcast.net
Fri, 28 Jun 2002 19:25:24 -0400
[Tim]
> ...
> The mystery to me now is why the a,b,c,d,e loop didn't happen in 2.2.1.
Because 2.2.1 has a bug in PyCFunction_New(), which ends with
op->m_self = self;
PyObject_GC_Init(op);
return (PyObject *)op;
But also in 2.2.1,
/* This is here for the sake of backwards compatibility. Extensions that
* use the old GC API will still compile but the objects will not be
* tracked by the GC. */
#define PyGC_HEAD_SIZE 0
#define PyObject_GC_Init(op)
#define PyObject_GC_Fini(op)
#define PyObject_AS_GC(op) (op)
#define PyObject_FROM_GC(op) (op)
IOW, PyObject_GC_Init(op) is a nop in 2.2.1, and the bound method object
never gets tracked. Therefore the a,b,c,d,e loop never gets started.
In current CVS, the function ends with
op->m_self = self;
_PyObject_GC_TRACK(op);
return (PyObject *)op;
and a world of fun follows <wink>.