Merged revisions 65654 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65654 | martin.v.loewis | 2008-08-12 16:49:50 +0200 (Tue, 12 Aug 2008) | 6 lines
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*.
........
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 3b79d05..b499b47 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4894,15 +4894,16 @@
static PyObject *
posix_write(PyObject *self, PyObject *args)
{
+ Py_buffer pbuf;
int fd;
Py_ssize_t size;
- char *buffer;
- if (!PyArg_ParseTuple(args, "is#:write", &fd, &buffer, &size))
+ if (!PyArg_ParseTuple(args, "is*:write", &fd, &pbuf))
return NULL;
Py_BEGIN_ALLOW_THREADS
- size = write(fd, buffer, (size_t)size);
+ size = write(fd, pbuf.buf, (size_t)pbuf.len);
Py_END_ALLOW_THREADS
+ PyBuffer_Release(&pbuf);
if (size < 0)
return posix_error();
return PyLong_FromSsize_t(size);