summaryrefslogtreecommitdiff
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-08-10 10:41:52 -0700
committerRaymond Hettinger <python@rcn.com>2014-08-10 10:41:52 -0700
commitd4cc49f5f367f488379150588d07c7f77dc917e5 (patch)
tree97b4a85c63fe35d488668f2f3d9652231431a572 /Objects/methodobject.c
parent9aebd07ac628842838a281dad04c891c410b0396 (diff)
parent7f8878040c398fac32114fb7072cfabf7f7f3fa6 (diff)
downloadcpython-d4cc49f5f367f488379150588d07c7f77dc917e5.tar.gz
merge
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index f2616d4ef0..686baf9ece 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -37,6 +37,7 @@ PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
if (op == NULL)
return NULL;
}
+ op->m_weakreflist = NULL;
op->m_ml = ml;
Py_XINCREF(self);
op->m_self = self;
@@ -147,6 +148,9 @@ static void
meth_dealloc(PyCFunctionObject *m)
{
_PyObject_GC_UNTRACK(m);
+ if (m->m_weakreflist != NULL) {
+ PyObject_ClearWeakRefs((PyObject*) m);
+ }
Py_XDECREF(m->m_self);
Py_XDECREF(m->m_module);
if (numfree < PyCFunction_MAXFREELIST) {
@@ -352,7 +356,7 @@ PyTypeObject PyCFunction_Type = {
(traverseproc)meth_traverse, /* tp_traverse */
0, /* tp_clear */
meth_richcompare, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
+ offsetof(PyCFunctionObject, m_weakreflist), /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
meth_methods, /* tp_methods */