]> granicus.if.org Git - python/commitdiff
Issue #10293: Remove obsolete field in the PyMemoryView structure,
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 4 Nov 2010 20:30:33 +0000 (20:30 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 4 Nov 2010 20:30:33 +0000 (20:30 +0000)
unused undocumented value PyBUF_SHADOW, and strangely-looking code in
PyMemoryView_GetContiguous.

Include/memoryobject.h
Include/object.h
Lib/test/test_sys.py
Misc/NEWS
Objects/memoryobject.c

index bf0b621ab92759ddb8eeb87ad80f98d4982c9f33..5bbfb05ab57ffa36195491ae5f7004ab279d33c6 100644 (file)
@@ -63,7 +63,6 @@ PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info);
    and functions instead! */
 typedef struct {
     PyObject_HEAD
-    PyObject *base;
     Py_buffer view;
 } PyMemoryViewObject;
 
index f14fd07a04a2dedf2916b20e75f1a4cafc159594..bc528fdee1ffee27e00d1353f19bf4cd6ec1ad29 100644 (file)
@@ -189,7 +189,6 @@ typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
 
 #define PyBUF_READ  0x100
 #define PyBUF_WRITE 0x200
-#define PyBUF_SHADOW 0x400
 
 /* End buffer interface */
 
index 5736b44658e214a0405799a9e3e392b1a86dcafd..a5c9115edbdc0d65d8699b128c1f177dd5356cf5 100644 (file)
@@ -759,7 +759,7 @@ class SizeofTest(unittest.TestCase):
         check(int(PyLong_BASE**2-1), size(vh) + 2*self.longdigit)
         check(int(PyLong_BASE**2), size(vh) + 3*self.longdigit)
         # memory
-        check(memoryview(b''), size(h + 'P PP2P2i7P'))
+        check(memoryview(b''), size(h + 'PP2P2i7P'))
         # module
         check(unittest, size(h + '3P'))
         # None
index 39c3bf07bc98243729003f4be6e991944548b711..50bc33a58abc3f9006f122068361e3a6b125b47f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,10 @@ What's New in Python 3.2 Beta 1?
 Core and Builtins
 -----------------
 
+- Issue #10293: Remove obsolete field in the PyMemoryView structure,
+  unused undocumented value PyBUF_SHADOW, and strangely-looking code in
+  PyMemoryView_GetContiguous.
+
 - Issue #6081: Add str.format_map, similar to str.format(**mapping).
 
 - If FileIO.__init__ fails, close the file descriptor.
index 432673091da838ee0e3fb389bbfcc8c148ddb2de..ba9e08b9ab058d5599135a95dfd4f5ffe98eb222 100644 (file)
@@ -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;
 }