Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d91eec9

Browse files
committed
Re-enable GC of method objects.
1 parent dbf409f commit d91eec9

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

Objects/methodobject.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ PyCFunction_New(PyMethodDef *ml, PyObject *self)
1515
PyObject_INIT(op, &PyCFunction_Type);
1616
}
1717
else {
18-
op = PyObject_NEW(PyCFunctionObject, &PyCFunction_Type);
18+
op = PyObject_GC_New(PyCFunctionObject, &PyCFunction_Type);
1919
if (op == NULL)
2020
return NULL;
2121
}
2222
op->m_ml = ml;
2323
Py_XINCREF(self);
2424
op->m_self = self;
25-
PyObject_GC_Init(op);
25+
_PyObject_GC_TRACK(op);
2626
return (PyObject *)op;
2727
}
2828

@@ -111,7 +111,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
111111
static void
112112
meth_dealloc(PyCFunctionObject *m)
113113
{
114-
PyObject_GC_Fini(m);
114+
_PyObject_GC_UNTRACK(m);
115115
Py_XDECREF(m->m_self);
116116
m->m_self = (PyObject *)free_list;
117117
free_list = m;
@@ -216,7 +216,7 @@ PyTypeObject PyCFunction_Type = {
216216
PyObject_HEAD_INIT(&PyType_Type)
217217
0,
218218
"builtin_function_or_method",
219-
sizeof(PyCFunctionObject) + PyGC_HEAD_SIZE,
219+
sizeof(PyCFunctionObject),
220220
0,
221221
(destructor)meth_dealloc, /* tp_dealloc */
222222
0, /* tp_print */
@@ -233,7 +233,7 @@ PyTypeObject PyCFunction_Type = {
233233
PyObject_GenericGetAttr, /* tp_getattro */
234234
0, /* tp_setattro */
235235
0, /* tp_as_buffer */
236-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /* tp_flags */
236+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
237237
0, /* tp_doc */
238238
(traverseproc)meth_traverse, /* tp_traverse */
239239
0, /* tp_clear */
@@ -327,7 +327,6 @@ PyCFunction_Fini(void)
327327
while (free_list) {
328328
PyCFunctionObject *v = free_list;
329329
free_list = (PyCFunctionObject *)(v->m_self);
330-
v = (PyCFunctionObject *) PyObject_AS_GC(v);
331-
PyObject_DEL(v);
330+
PyObject_GC_Del(v);
332331
}
333332
}

0 commit comments

Comments
 (0)