Message162905
> 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. |
|
Date |
User |
Action |
Args |
2012-06-15 14:41:19 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, jaraco, pitrou, Arfrever, r.david.murray, docs@python, zach.ware, jgeralnik |
2012-06-15 14:41:19 | serhiy.storchaka | link | issue15068 messages |
2012-06-15 14:41:18 | serhiy.storchaka | create | |
|