diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-06-03 05:59:20 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-06-03 05:59:20 (GMT) |
commit | c9813d83f78c1eed12aebc286d6df0e9a5d90d04 (patch) | |
tree | ad5967e5bcc619be26198efbf78502578e5da615 /Modules | |
parent | 9aabaccb7632a35da37b3d9c58b6ee0aab3ac547 (diff) | |
download | cpython-c9813d83f78c1eed12aebc286d6df0e9a5d90d04.zip cpython-c9813d83f78c1eed12aebc286d6df0e9a5d90d04.tar.gz cpython-c9813d83f78c1eed12aebc286d6df0e9a5d90d04.tar.bz2 |
Issue #20699: Document that “io” methods should accept memoryview
This matches the usage by BufferedReader, BufferedWriter, etc. Also document
and test that the write() methods should only access their argument before
they return.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/bufferedio.c | 3 | ||||
-rw-r--r-- | Modules/_io/bytesio.c | 2 | ||||
-rw-r--r-- | Modules/_io/fileio.c | 2 | ||||
-rw-r--r-- | Modules/_io/iobase.c | 6 |
4 files changed, 7 insertions, 6 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 600bf8a..5bef746 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -125,8 +125,7 @@ bufferediobase_read1(PyObject *self, PyObject *args) PyDoc_STRVAR(bufferediobase_write_doc, "Write the given buffer to the IO stream.\n" "\n" - "Returns the number of bytes written, which is never less than\n" - "len(b).\n" + "Returns the number of bytes written, which is always len(b).\n" "\n" "Raises BlockingIOError if the buffer is full and the\n" "underlying raw stream cannot accept more data at the moment.\n"); diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index d575236..1335ae8 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -392,7 +392,7 @@ bytesio_readlines(bytesio *self, PyObject *args) } PyDoc_STRVAR(readinto_doc, -"readinto(bytearray) -> int. Read up to len(b) bytes into b.\n" +"readinto(b) -> int. Read up to len(b) bytes into b.\n" "\n" "Returns number of bytes read (0 for EOF), or None if the object\n" "is set not to block and has no data to read."); diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 098aef4..74b2305 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -969,7 +969,7 @@ PyDoc_STRVAR(readall_doc, "or None if no data is available. On end-of-file, returns ''."); PyDoc_STRVAR(write_doc, -"write(b: bytes) -> int. Write bytes b to file, return number written.\n" +"write(b) -> int. Write array of bytes b, return number written.\n" "\n" "Only makes one system call, so not all of the data may be written.\n" "The number of bytes actually written is returned. In non-blocking mode,\n" diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 61756d0..710ada4 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -38,8 +38,10 @@ PyDoc_STRVAR(iobase_doc, "may raise a IOError when operations they do not support are called.\n" "\n" "The basic type used for binary data read from or written to a file is\n" - "bytes. bytearrays are accepted too, and in some cases (such as\n" - "readinto) needed. Text I/O classes work with str data.\n" + "the bytes type. Method arguments may also be bytearray or memoryview\n" + "of arrays of bytes. In some cases, such as readinto, a writable\n" + "object such as bytearray is required. Text I/O classes work with\n" + "unicode data.\n" "\n" "Note that calling any method (except additional calls to close(),\n" "which are ignored) on a closed stream should raise a ValueError.\n" |