diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-04 20:30:33 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-04 20:30:33 (GMT) |
commit | aeb6ceead796af4746f5b2f816b23654816033b7 (patch) | |
tree | 9836b77eb1f4868f39bc499d3c6d8abe3f13bbca /Objects/memoryobject.c | |
parent | 8f2e07b7d0510a008bcf63640ebe66d397e0bf52 (diff) | |
download | cpython-aeb6ceead796af4746f5b2f816b23654816033b7.zip cpython-aeb6ceead796af4746f5b2f816b23654816033b7.tar.gz cpython-aeb6ceead796af4746f5b2f816b23654816033b7.tar.bz2 |
Issue #10293: Remove obsolete field in the PyMemoryView structure,
unused undocumented value PyBUF_SHADOW, and strangely-looking code in
PyMemoryView_GetContiguous.
Diffstat (limited to 'Objects/memoryobject.c')
-rw-r--r-- | Objects/memoryobject.c | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 4326730..ba9e08b 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -82,7 +82,6 @@ PyMemoryView_FromBuffer(Py_buffer *info) PyObject_GC_New(PyMemoryViewObject, &PyMemoryView_Type); if (mview == NULL) return NULL; - mview->base = NULL; dup_buffer(&mview->view, info); /* NOTE: mview->view.obj should already have been incref'ed as part of PyBuffer_FillInfo(). */ @@ -112,8 +111,6 @@ PyMemoryView_FromObject(PyObject *base) return NULL; } - mview->base = base; - Py_INCREF(base); return (PyObject *)mview; } @@ -291,8 +288,6 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort) if (PyBuffer_IsContiguous(view, fort)) { /* no copy needed */ - Py_INCREF(obj); - mem->base = obj; _PyObject_GC_TRACK(mem); return (PyObject *)mem; } @@ -324,21 +319,7 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort) Py_DECREF(mem); return NULL; } - } - if (buffertype == PyBUF_SHADOW) { - /* return a shadowed memory-view object */ - view->buf = dest; - mem->base = PyTuple_Pack(2, obj, bytes); - Py_DECREF(bytes); - if (mem->base == NULL) { - Py_DECREF(mem); - return NULL; - } - } - else { PyBuffer_Release(view); /* XXX ? */ - /* steal the reference */ - mem->base = bytes; } _PyObject_GC_TRACK(mem); return (PyObject *)mem; @@ -481,28 +462,7 @@ static void do_release(PyMemoryViewObject *self) { if (self->view.obj != NULL) { - if (self->base && PyTuple_Check(self->base)) { - /* Special case when first element is generic object - with buffer interface and the second element is a - contiguous "shadow" that must be copied back into - the data areay of the first tuple element before - releasing the buffer on the first element. - */ - - PyObject_CopyData(PyTuple_GET_ITEM(self->base,0), - PyTuple_GET_ITEM(self->base,1)); - - /* The view member should have readonly == -1 in - this instance indicating that the memory can - be "locked" and was locked and will be unlocked - again after this call. - */ - PyBuffer_Release(&(self->view)); - } - else { - PyBuffer_Release(&(self->view)); - } - Py_CLEAR(self->base); + PyBuffer_Release(&(self->view)); } self->view.obj = NULL; self->view.buf = NULL; @@ -819,8 +779,6 @@ _notimpl: static int memory_traverse(PyMemoryViewObject *self, visitproc visit, void *arg) { - if (self->base != NULL) - Py_VISIT(self->base); if (self->view.obj != NULL) Py_VISIT(self->view.obj); return 0; @@ -829,7 +787,6 @@ memory_traverse(PyMemoryViewObject *self, visitproc visit, void *arg) static int memory_clear(PyMemoryViewObject *self) { - Py_CLEAR(self->base); PyBuffer_Release(&self->view); return 0; } |