]> granicus.if.org Git - python/commitdiff
Remove locking from buffer protocol as-per discussion.
authorTravis E. Oliphant <oliphant@enthought.com>
Fri, 6 Jun 2008 20:52:38 +0000 (20:52 +0000)
committerTravis E. Oliphant <oliphant@enthought.com>
Fri, 6 Jun 2008 20:52:38 +0000 (20:52 +0000)
Include/object.h
Modules/_bsddb.c
Modules/_ctypes/_ctypes.c
Modules/arraymodule.c
Objects/abstract.c
Objects/memoryobject.c

index 62c4961380a3055bd722a98b7548fb2921ea3039..e924131b61f1c86e47f9c044feedf18708db9236 100644 (file)
@@ -163,7 +163,6 @@ typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
 #define PyBUF_WRITABLE 0x0001
 /*  we used to include an E, backwards compatible alias  */
 #define PyBUF_WRITEABLE PyBUF_WRITABLE
-#define PyBUF_LOCK 0x0002
 #define PyBUF_FORMAT 0x0004
 #define PyBUF_ND 0x0008
 #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
@@ -174,25 +173,15 @@ typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
 
 #define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
 #define PyBUF_CONTIG_RO (PyBUF_ND)
-#define PyBUF_CONTIG_LCK (PyBUF_ND | PyBUF_LOCK)
-#define PyBUF_CONTIG_XLCK (PyBUF_ND | PyBUF_LOCK | PyBUF_WRITABLE)
 
 #define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
 #define PyBUF_STRIDED_RO (PyBUF_STRIDES)
-#define PyBUF_STRIDED_LCK (PyBUF_STRIDES | PyBUF_LOCK)
-#define PyBUF_STRIDED_XLCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_WRITABLE)
 
 #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
 #define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
-#define PyBUF_RECORDS_LCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_FORMAT)
-#define PyBUF_RECORDS_XLCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_WRITABLE \
-                           | PyBUF_FORMAT)
 
 #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
 #define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
-#define PyBUF_FULL_LCK (PyBUF_INDIRECT | PyBUF_LOCK | PyBUF_FORMAT)
-#define PyBUF_FULL_XLCK (PyBUF_INDIRECT | PyBUF_LOCK | PyBUF_WRITABLE \
-                        | PyBUF_FORMAT)
 
 
 #define PyBUF_READ  0x100
index 04c38356643d72207b3c6cad5b1d37210cabb27b..3a67a1e600a8c5f2db0e34434afd87a21230567c 100644 (file)
@@ -312,12 +312,6 @@ static Py_buffer * _malloc_view(PyObject *obj)
                         "Py_buffer malloc failed");
         return NULL;
     }
-    /* We use PyBUF_LOCK to prevent other threads from trashing the data
-       buffer while we release the GIL.  http://bugs.python.org/issue1035 */
-    if (PyObject_GetBuffer(obj, view, PyBUF_LOCK) == -1) {
-        PyMem_Free(view);
-        return NULL;
-    }
     if (view->ndim > 1) {
         PyErr_SetString(PyExc_BufferError,
                         "buffers must be single dimension");
index fe598d770fe906ec67e18fcb886b9bca0670c86c..c840757add866e2f6572e1a2eb183a280238285e 100644 (file)
@@ -2449,11 +2449,6 @@ static int CData_GetBuffer(PyObject *_self, Py_buffer *view, int flags)
        Py_ssize_t i;
 
        if (view == NULL) return 0;
-       if (((flags & PyBUF_LOCK) == PyBUF_LOCK)) {
-               PyErr_SetString(PyExc_BufferError,
-                               "Cannot lock this object.");
-               return -1;
-       }
 
        view->buf = self->b_ptr;
        view->len = self->b_size;
index a84126d12b3cb599c318b7cf62d7f92a9b63d712..ea59a426abfed725cd27141ba06cfaaab819bf3f 100644 (file)
@@ -1779,11 +1779,6 @@ static const void *emptybuf = "";
 static int
 array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags)
 {
-        if ((flags & PyBUF_LOCK)) {
-                PyErr_SetString(PyExc_BufferError,
-                                "Cannot lock data");
-                return -1;
-        }
         if (view==NULL) goto finish;
 
         view->buf = (void *)self->ob_item;
index 11adc772ad83348ea59dc6e576c2beff394cc460..60a5e849cfddc8768af29a0d160520df45c7c255 100644 (file)
@@ -672,12 +672,6 @@ PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len,
              int readonly, int flags)
 {
        if (view == NULL) return 0;
-       if (((flags & PyBUF_LOCK) == PyBUF_LOCK) &&
-           readonly != 0) {
-               PyErr_SetString(PyExc_BufferError,
-                               "Cannot lock this object.");
-               return -1;
-       }
        if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
            (readonly == 1)) {
                PyErr_SetString(PyExc_BufferError,
index 27ceb7a2e5244745c820f71f87f2d0251c2017c7..9bb16971d6a37fba1dac3b7e0bbd4eec878bb0e8 100644 (file)
@@ -230,9 +230,6 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort)
         case PyBUF_WRITE:
                 flags = PyBUF_FULL;
                 break;
-        case PyBUF_SHADOW:
-                flags = PyBUF_FULL_XLCK;
-                break;
         }
 
         if (PyObject_GetBuffer(obj, view, flags) != 0) {