Skip to content

Commit cfd7bdc

Browse files
author
travis.oliphant
committed
Remove locking from buffer protocol as-per discussion.
git-svn-id: http://svn.python.org/projects/python/branches/py3k@63994 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent e9cb06d commit cfd7bdc

6 files changed

Lines changed: 0 additions & 36 deletions

File tree

Include/object.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
163163
#define PyBUF_WRITABLE 0x0001
164164
/* we used to include an E, backwards compatible alias */
165165
#define PyBUF_WRITEABLE PyBUF_WRITABLE
166-
#define PyBUF_LOCK 0x0002
167166
#define PyBUF_FORMAT 0x0004
168167
#define PyBUF_ND 0x0008
169168
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
@@ -174,25 +173,15 @@ typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
174173

175174
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
176175
#define PyBUF_CONTIG_RO (PyBUF_ND)
177-
#define PyBUF_CONTIG_LCK (PyBUF_ND | PyBUF_LOCK)
178-
#define PyBUF_CONTIG_XLCK (PyBUF_ND | PyBUF_LOCK | PyBUF_WRITABLE)
179176

180177
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
181178
#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
182-
#define PyBUF_STRIDED_LCK (PyBUF_STRIDES | PyBUF_LOCK)
183-
#define PyBUF_STRIDED_XLCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_WRITABLE)
184179

185180
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
186181
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
187-
#define PyBUF_RECORDS_LCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_FORMAT)
188-
#define PyBUF_RECORDS_XLCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_WRITABLE \
189-
| PyBUF_FORMAT)
190182

191183
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
192184
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
193-
#define PyBUF_FULL_LCK (PyBUF_INDIRECT | PyBUF_LOCK | PyBUF_FORMAT)
194-
#define PyBUF_FULL_XLCK (PyBUF_INDIRECT | PyBUF_LOCK | PyBUF_WRITABLE \
195-
| PyBUF_FORMAT)
196185

197186

198187
#define PyBUF_READ 0x100

Modules/_bsddb.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,6 @@ static Py_buffer * _malloc_view(PyObject *obj)
312312
"Py_buffer malloc failed");
313313
return NULL;
314314
}
315-
/* We use PyBUF_LOCK to prevent other threads from trashing the data
316-
buffer while we release the GIL. http://bugs.python.org/issue1035 */
317-
if (PyObject_GetBuffer(obj, view, PyBUF_LOCK) == -1) {
318-
PyMem_Free(view);
319-
return NULL;
320-
}
321315
if (view->ndim > 1) {
322316
PyErr_SetString(PyExc_BufferError,
323317
"buffers must be single dimension");

Modules/_ctypes/_ctypes.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,11 +2449,6 @@ static int CData_GetBuffer(PyObject *_self, Py_buffer *view, int flags)
24492449
Py_ssize_t i;
24502450

24512451
if (view == NULL) return 0;
2452-
if (((flags & PyBUF_LOCK) == PyBUF_LOCK)) {
2453-
PyErr_SetString(PyExc_BufferError,
2454-
"Cannot lock this object.");
2455-
return -1;
2456-
}
24572452

24582453
view->buf = self->b_ptr;
24592454
view->len = self->b_size;

Modules/arraymodule.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,11 +1779,6 @@ static const void *emptybuf = "";
17791779
static int
17801780
array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags)
17811781
{
1782-
if ((flags & PyBUF_LOCK)) {
1783-
PyErr_SetString(PyExc_BufferError,
1784-
"Cannot lock data");
1785-
return -1;
1786-
}
17871782
if (view==NULL) goto finish;
17881783

17891784
view->buf = (void *)self->ob_item;

Objects/abstract.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,6 @@ PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len,
672672
int readonly, int flags)
673673
{
674674
if (view == NULL) return 0;
675-
if (((flags & PyBUF_LOCK) == PyBUF_LOCK) &&
676-
readonly != 0) {
677-
PyErr_SetString(PyExc_BufferError,
678-
"Cannot lock this object.");
679-
return -1;
680-
}
681675
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
682676
(readonly == 1)) {
683677
PyErr_SetString(PyExc_BufferError,

Objects/memoryobject.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort)
230230
case PyBUF_WRITE:
231231
flags = PyBUF_FULL;
232232
break;
233-
case PyBUF_SHADOW:
234-
flags = PyBUF_FULL_XLCK;
235-
break;
236233
}
237234

238235
if (PyObject_GetBuffer(obj, view, flags) != 0) {

0 commit comments

Comments
 (0)