Signals and readline()

Bob Alexander balexander at rsv.ricoh.com
Tue May 1 00:01:47 EDT 2001


> > The current behavior is bad because there is no way to distinguish
> between the
> > incorrect empty line and a real end of file.
>
> That's not true.  An empty line is '\n' and end-of-file is ''.
>
> Jeff
>
Jeff --

Note that what I'm discussing here is incorrect behavior when readline()
is interrupted by a signal -- not the normal readline() EOF indication.
When I said that readline() incorrectly returned an empty line when
interrupted by a signal, I meant a *real* empty line: the zero-length
string (I guess I should have said empty _string_). After the signal,
further readline()s returned more data. Thus when interrupted by a
signal, the value returned by readline() is indistinguishable from an
end fo file. Since there was more data to be read, though, it wasn't a
real end of file.

By the way, since there's so much talk about Ruby on this list lately,
I ported my test program that shows this bug to Ruby -- it worked fine!

Also by the way, my results are with Python 2.0 -- haven't tried this
with 2.1.

Bob





More information about the Python-list mailing list