Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e83ed43

Browse files
committed
improve description of buffers argument for readv/writev (closes #17811)
Patch by Nikolaus Rath.
1 parent a96860c commit e83ed43

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

Doc/library/os.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,13 @@ as internal buffering of data.
10191019

10201020
.. function:: readv(fd, buffers)
10211021

1022-
Read from a file descriptor into a number of writable buffers. *buffers* is
1023-
an arbitrary sequence of writable buffers. Returns the total number of bytes
1024-
read.
1025-
1022+
Read from a file descriptor *fd* into a number of mutable :term:`bytes-like
1023+
objects <bytes-like object>` *buffers*. :func:`~os.readv` will transfer data
1024+
into each buffer until it is full and then move on to the next buffer in the
1025+
sequence to hold the rest of the data. :func:`~os.readv` returns the total
1026+
number of bytes read (which may be less than the total capacity of all the
1027+
objects).
1028+
10261029
Availability: Unix.
10271030

10281031
.. versionadded:: 3.3
@@ -1071,10 +1074,11 @@ as internal buffering of data.
10711074

10721075
.. function:: writev(fd, buffers)
10731076

1074-
Write the contents of *buffers* to file descriptor *fd*, where *buffers*
1075-
is an arbitrary sequence of buffers.
1076-
Returns the total number of bytes written.
1077-
1077+
Write the contents of *buffers* to file descriptor *fd*. *buffers* must be a
1078+
sequence of :term:`bytes-like objects <bytes-like object>`.
1079+
:func:`~os.writev` writes the contents of each object to the file descriptor
1080+
and returns the total number of bytes written.
1081+
10781082
Availability: Unix.
10791083

10801084
.. versionadded:: 3.3

Modules/posixmodule.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8100,9 +8100,12 @@ iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt)
81008100
#ifdef HAVE_READV
81018101
PyDoc_STRVAR(posix_readv__doc__,
81028102
"readv(fd, buffers) -> bytesread\n\n\
8103-
Read from a file descriptor into a number of writable buffers. buffers\n\
8104-
is an arbitrary sequence of writable buffers.\n\
8105-
Returns the total number of bytes read.");
8103+
Read from a file descriptor fd into a number of mutable, bytes-like\n\
8104+
objects (\"buffers\"). readv will transfer data into each buffer\n\
8105+
until it is full and then move on to the next buffer in the sequence\n\
8106+
to hold the rest of the data.\n\n\
8107+
readv returns the total number of bytes read (which may be less than\n\
8108+
the total capacity of all the buffers.");
81068109

81078110
static PyObject *
81088111
posix_readv(PyObject *self, PyObject *args)
@@ -8465,9 +8468,10 @@ posix_pipe2(PyObject *self, PyObject *arg)
84658468
#ifdef HAVE_WRITEV
84668469
PyDoc_STRVAR(posix_writev__doc__,
84678470
"writev(fd, buffers) -> byteswritten\n\n\
8468-
Write the contents of buffers to a file descriptor, where buffers is an\n\
8469-
arbitrary sequence of buffers.\n\
8470-
Returns the total bytes written.");
8471+
Write the contents of *buffers* to file descriptor *fd*. *buffers*\n\
8472+
must be a sequence of bytes-like objects.\n\n\
8473+
writev writes the contents of each object to the file descriptor\n\
8474+
and returns the total number of bytes written.");
84718475

84728476
static PyObject *
84738477
posix_writev(PyObject *self, PyObject *args)

0 commit comments

Comments
 (0)