Visit the closure during traversal and XDECREF it on during deallocation.
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 0282242..8871e0a 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -252,6 +252,7 @@
Py_XDECREF(op->func_defaults);
Py_XDECREF(op->func_doc);
Py_XDECREF(op->func_dict);
+ Py_XDECREF(op->func_closure);
op = (PyFunctionObject *) PyObject_AS_GC(op);
PyObject_DEL(op);
}
@@ -303,6 +304,11 @@
if (err)
return err;
}
+ if (f->func_closure) {
+ err = visit(f->func_closure, arg);
+ if (err)
+ return err;
+ }
return 0;
}