Index: Modules/gcmodule.c =================================================================== --- Modules/gcmodule.c (revision 86684) +++ Modules/gcmodule.c (working copy) @@ -68,6 +68,9 @@ /* Python string used to look for __del__ attribute. */ static PyObject *delstr = NULL; +/* a list of callbacks to be invoked when collection is performed */ +static PyObject *callbacks = NULL; + /* This is the number of objects who survived the last full collection. It approximates the number of long lived objects tracked by the GC. @@ -942,12 +945,29 @@ return n+m; } +static void +invoke_gc_callback(int phase) +{ + int i; + for (i=0; i is @@ -1393,6 +1425,7 @@ Py_XDECREF(bytes); } } + Py_CLEAR(callbacks); } /* for debugging */