diff options
| author | Martin v. Löwis <martin@v.loewis.de> | 2008-08-12 14:49:50 +0000 |
|---|---|---|
| committer | Martin v. Löwis <martin@v.loewis.de> | 2008-08-12 14:49:50 +0000 |
| commit | f91d46a17d85da323895950852093117bc21f860 (patch) | |
| tree | c6a3e68cf22a6a102f9c1dc780438f0307b6588f /Include | |
| parent | aa8efbf08469c3667ed22362c0e10b83ae124c0b (diff) | |
| download | cpython-git-f91d46a17d85da323895950852093117bc21f860.tar.gz | |
Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
by denying s# to parse objects that have a releasebuffer procedure,
and introducing s*.
More module might need to get converted to use s*.
Diffstat (limited to 'Include')
| -rw-r--r-- | Include/abstract.h | 25 | ||||
| -rw-r--r-- | Include/object.h | 3 |
2 files changed, 8 insertions, 20 deletions
diff --git a/Include/abstract.h b/Include/abstract.h index 3e5cf129f8..04c007a47d 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -549,24 +549,6 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ */ - PyAPI_FUNC(void) PyObject_ReleaseBuffer(PyObject *obj, Py_buffer *view); - - - /* C-API version of the releasebuffer function call. It - checks to make sure the object has the required function - pointer and issues the call. The obj must have the buffer - interface or this function will cause a segfault (i.e. it - is assumed to be called only after a corresponding - getbuffer which already verified the existence of the - tp_as_buffer pointer). - - Returns 0 on success and -1 (with an error raised) on - failure. This function always succeeds (as a NO-OP) if - there is no releasebuffer function for the object so that - it can always be called when the consumer is done with the - buffer - */ - PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices); /* Get the memory area pointed to by the indices for the buffer given. @@ -623,7 +605,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ per element. */ - PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, void *buf, + PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, Py_ssize_t len, int readonly, int flags); @@ -633,6 +615,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ and -1 (with raising an error) on error. */ + PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view); + + /* Releases a Py_buffer obtained from getbuffer ParseTuple's s*. + */ + PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj, PyObject *format_spec); /* diff --git a/Include/object.h b/Include/object.h index c00df74e6e..6c04034039 100644 --- a/Include/object.h +++ b/Include/object.h @@ -162,7 +162,8 @@ typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **); /* Py3k buffer interface */ typedef struct bufferinfo { - void *buf; + void *buf; + PyObject *obj; /* borrowed reference */ Py_ssize_t len; Py_ssize_t itemsize; /* This is Py_ssize_t so it can be pointed to by strides in simple case.*/ |
