diff options
author | Richard Oudkerk <shibturn@gmail.com> | 2012-05-28 20:35:09 (GMT) |
---|---|---|
committer | Richard Oudkerk <shibturn@gmail.com> | 2012-05-28 20:35:09 (GMT) |
commit | 3e0a1eb8890c25b9d1f98bc2f4a4bbe2a0cdfdce (patch) | |
tree | 3b5e75991f7a5e61aea0f6282fec4d7c00c7cc12 /Objects | |
parent | 1cfe7d9a84d5f4d8950f2b5a82be3bb25a725b62 (diff) | |
download | cpython-3e0a1eb8890c25b9d1f98bc2f4a4bbe2a0cdfdce.zip cpython-3e0a1eb8890c25b9d1f98bc2f4a4bbe2a0cdfdce.tar.gz cpython-3e0a1eb8890c25b9d1f98bc2f4a4bbe2a0cdfdce.tar.bz2 |
Issue #14930: Make memoryview objects weakrefable.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/memoryobject.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 67f7e01..62427d4 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -595,6 +595,7 @@ memory_alloc(int ndim) mv->view.shape = mv->ob_array; mv->view.strides = mv->ob_array + ndim; mv->view.suboffsets = mv->ob_array + 2 * ndim; + mv->weakreflist = NULL; _PyObject_GC_TRACK(mv); return mv; @@ -969,6 +970,8 @@ memory_dealloc(PyMemoryViewObject *self) _PyObject_GC_UNTRACK(self); (void)_memory_release(self); Py_CLEAR(self->mbuf); + if (self->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) self); PyObject_GC_Del(self); } @@ -2608,7 +2611,7 @@ PyTypeObject PyMemoryView_Type = { (traverseproc)memory_traverse, /* tp_traverse */ (inquiry)memory_clear, /* tp_clear */ memory_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ + offsetof(PyMemoryViewObject, weakreflist),/* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ memory_methods, /* tp_methods */ |