[Python-Dev] fileobj.read(float): warning or error?

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Sep 3 03:27:56 CEST 2008


Jesus Cea wrote:

> My point is: we are simplifying the program considering "0" a valid len
> counter, but we complicates it because now the code can't consider "" =
> EOF if it actually asked for 0 bytes.

What are you suggesting read(0) *should* do, then?
If it returns None or some other special value, or
raises an exception, then you need a special case
to handle that. So you've just substituted one special
case for another.

 > Isaac Morland wrote:
 >
> > The Unix read() system call doesn't treat EOF as special other than it
> > won't return bytes from "beyond" EOF and therefore even when reading a
> > regular file could return fewer (including 0) bytes than asked for in
> > the call.

No, that's not right -- a read of more than 0 bytes will
always block until at least 1 byte is available, or
something happens that counts as an EOF condition.

However, with some devices it's possible for what
counts as EOF to happen more than once, e.g. ttys.

-- 
Greg


More information about the Python-Dev mailing list