# HG changeset patch # Parent 154ae3af03173ce0f735b6dd47a37da97910f0b9 BufferedReader.peek() normally returns at least one byte diff -r 154ae3af0317 -r 33431551b059 Doc/library/io.rst --- a/Doc/library/io.rst Fri Jan 09 16:40:38 2015 -0600 +++ b/Doc/library/io.rst Sat Jan 10 04:10:37 2015 +0000 @@ -636,7 +636,9 @@ Return bytes from the stream without advancing the position. At most one single read on the raw stream is done to satisfy the call. The number of - bytes returned may be less or more than requested. + bytes returned may be less or more than requested, but is + guaranteed to be at least one, unless no data is available due to + EOF or non-blocking mode. .. method:: read([size]) diff -r 154ae3af0317 -r 33431551b059 Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c Fri Jan 09 16:40:38 2015 -0600 +++ b/Modules/_io/bufferedio.c Sat Jan 10 04:10:37 2015 +0000 @@ -1758,9 +1758,9 @@ /* Fill the buffer from the raw stream, and copy it to the result. */ _bufferedreader_reset_buf(self); r = _bufferedreader_fill_buffer(self); - if (r == -1) + if (r == -1) /* Exception raised */ return NULL; - if (r == -2) + if (r == -2) /* No data in non-blocking mode */ r = 0; self->pos = 0; return PyBytes_FromStringAndSize(self->buffer, r);