diff options
author | Fred Drake <fdrake@acm.org> | 2001-03-23 04:19:27 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-03-23 04:19:27 (GMT) |
commit | db81e8ddf8953359e8c2ed9569dd2e774d78ae95 (patch) | |
tree | ee907202cd30873818f01817b57f1652631af918 /Objects/classobject.c | |
parent | 6a1c87ddf9033570bb773ffec5190d44e70bd5a1 (diff) | |
download | cpython-db81e8ddf8953359e8c2ed9569dd2e774d78ae95.zip cpython-db81e8ddf8953359e8c2ed9569dd2e774d78ae95.tar.gz cpython-db81e8ddf8953359e8c2ed9569dd2e774d78ae95.tar.bz2 |
Add support for weak references to the function and method types.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index d7b4c1e..fa71c4e 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -1805,6 +1805,7 @@ PyMethod_New(PyObject *func, PyObject *self, PyObject *class) if (im == NULL) return NULL; } + im->im_weakreflist = NULL; Py_INCREF(func); im->im_func = func; Py_XINCREF(self); @@ -1902,6 +1903,7 @@ instancemethod_getattro(register PyMethodObject *im, PyObject *name) static void instancemethod_dealloc(register PyMethodObject *im) { + PyObject_ClearWeakRefs((PyObject *)im); PyObject_GC_Fini(im); Py_DECREF(im->im_func); Py_XDECREF(im->im_self); @@ -2019,9 +2021,12 @@ PyTypeObject PyMethod_Type = { (getattrofunc)instancemethod_getattro, /* tp_getattro */ (setattrofunc)instancemethod_setattro, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC | Py_TPFLAGS_HAVE_WEAKREFS, 0, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + offsetof(PyMethodObject, im_weakreflist) /* tp_weaklistoffset */ }; /* Clear out the free list */ |