diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-01-19 03:54:59 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-01-19 03:54:59 (GMT) |
commit | e83ed4328121747fc9b201497e3ebdaa43f90537 (patch) | |
tree | 95e684a6c9c4b736abb3424fa21654bd48cacebe | |
parent | a96860c91cabb94675c25435e8d11443abb70db7 (diff) | |
download | cpython-e83ed4328121747fc9b201497e3ebdaa43f90537.zip cpython-e83ed4328121747fc9b201497e3ebdaa43f90537.tar.gz cpython-e83ed4328121747fc9b201497e3ebdaa43f90537.tar.bz2 |
improve description of buffers argument for readv/writev (closes #17811)
Patch by Nikolaus Rath.
-rw-r--r-- | Doc/library/os.rst | 20 | ||||
-rw-r--r-- | Modules/posixmodule.c | 16 |
2 files changed, 22 insertions, 14 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 20f3e87..b11098e 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1019,10 +1019,13 @@ as internal buffering of data. .. function:: readv(fd, buffers) - Read from a file descriptor into a number of writable buffers. *buffers* is - an arbitrary sequence of writable buffers. Returns the total number of bytes - read. - + Read from a file descriptor *fd* into a number of mutable :term:`bytes-like + objects <bytes-like object>` *buffers*. :func:`~os.readv` will transfer data + into each buffer until it is full and then move on to the next buffer in the + sequence to hold the rest of the data. :func:`~os.readv` returns the total + number of bytes read (which may be less than the total capacity of all the + objects). + Availability: Unix. .. versionadded:: 3.3 @@ -1071,10 +1074,11 @@ as internal buffering of data. .. function:: writev(fd, buffers) - Write the contents of *buffers* to file descriptor *fd*, where *buffers* - is an arbitrary sequence of buffers. - Returns the total number of bytes written. - + Write the contents of *buffers* to file descriptor *fd*. *buffers* must be a + sequence of :term:`bytes-like objects <bytes-like object>`. + :func:`~os.writev` writes the contents of each object to the file descriptor + and returns the total number of bytes written. + Availability: Unix. .. versionadded:: 3.3 diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 905b1de..4b077a0 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -8100,9 +8100,12 @@ iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt) #ifdef HAVE_READV PyDoc_STRVAR(posix_readv__doc__, "readv(fd, buffers) -> bytesread\n\n\ -Read from a file descriptor into a number of writable buffers. buffers\n\ -is an arbitrary sequence of writable buffers.\n\ -Returns the total number of bytes read."); +Read from a file descriptor fd into a number of mutable, bytes-like\n\ +objects (\"buffers\"). readv will transfer data into each buffer\n\ +until it is full and then move on to the next buffer in the sequence\n\ +to hold the rest of the data.\n\n\ +readv returns the total number of bytes read (which may be less than\n\ +the total capacity of all the buffers."); static PyObject * posix_readv(PyObject *self, PyObject *args) @@ -8465,9 +8468,10 @@ posix_pipe2(PyObject *self, PyObject *arg) #ifdef HAVE_WRITEV PyDoc_STRVAR(posix_writev__doc__, "writev(fd, buffers) -> byteswritten\n\n\ -Write the contents of buffers to a file descriptor, where buffers is an\n\ -arbitrary sequence of buffers.\n\ -Returns the total bytes written."); +Write the contents of *buffers* to file descriptor *fd*. *buffers*\n\ +must be a sequence of bytes-like objects.\n\n\ +writev writes the contents of each object to the file descriptor\n\ +and returns the total number of bytes written."); static PyObject * posix_writev(PyObject *self, PyObject *args) |