Serhiy Storchaka <storch...@gmail.com> added the comment: > The patch I've attached checks if the number of bytes read from the file is > less than the size of the buffer (which means that the file has ended).
>From io.RawIOBase.read docs: """ Read up to n bytes from the object and return them. As a convenience, if n is unspecified or -1, readall() is called. Otherwise, only one system call is ever made. Fewer than n bytes may be returned if the operating system call returns fewer than n bytes. If 0 bytes are returned, and n was not 0, this indicates end of file. """ This is not an arbitrary assumption. In particular, when reading from a terminal with line buffering (you can edit the line until you press Enter) on C level you read only a whole line (if line length is not greater than buffer length) and 0 bytes you will receive only by pressing ^D or ^Z at the beginning of the line. Same for pipes and sockets. On Python level there are many third-party implementations of file-like objects which rely on this behavior, you cannot rewrite all of them. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15068> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com