From: Serhiy Storchaka Date: Thu, 9 Apr 2015 23:19:57 +0000 (+0300) Subject: Replaced "string" with "bytes object" in docstrings of binary I/O objects. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5056769b36901598b9eb3900a44839284e782b14;p=python Replaced "string" with "bytes object" in docstrings of binary I/O objects. --- 5056769b36901598b9eb3900a44839284e782b14 diff --cc Modules/_io/bytesio.c index fc4ea74b23,4652356f31..974e33ac2a --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@@ -304,31 -257,11 +304,31 @@@ bytesio_tell(bytesio *self return PyLong_FromSsize_t(self->pos); } +static PyObject * +read_bytes(bytesio *self, Py_ssize_t size) +{ + char *output; + + assert(self->buf != NULL); + assert(size <= self->string_size); + if (size > 1 && + self->pos == 0 && size == PyBytes_GET_SIZE(self->buf) && + self->exports == 0) { + self->pos += size; + Py_INCREF(self->buf); + return self->buf; + } + + output = PyBytes_AS_STRING(self->buf) + self->pos; + self->pos += size; + return PyBytes_FromStringAndSize(output, size); +} + PyDoc_STRVAR(read_doc, - "read([size]) -> read at most size bytes, returned as a string.\n" + "read([size]) -> read at most size bytes, returned as a bytes object.\n" "\n" "If the size argument is negative, read until EOF is reached.\n" - "Return an empty string at EOF."); + "Return an empty bytes object at EOF."); static PyObject * bytesio_read(bytesio *self, PyObject *args)