when does newlines get set in universal newlines mode?

Davide Mancusi arekfu at gmail.com
Mon May 4 09:35:46 EDT 2015


>> I believe this is a bug.
>
> I'm not sure it is, actually; imagine the text is coming in one
> character at a time (eg from a pipe), and it's seen "alpha\r". It
> knows that this is a line, so it emits it; but until the next
> character is read, it can't know whether it's going to be \r or \r\n.
> What should it do? Read another character, which might block? Put "\r"
> into .newlines, which might be wrong? Once it sees the \n, it knows
> that it was \r\n (or rather, it assumes that files do not have lines
> of text terminated by \r followed by blank lines terminated by \n -
> because that would be stupid).

I think this is a good point. However, I will probably submit a bug
report anyway and let the devs make their decisions. It is at least a
documentation bug.

Cheers,
Davide



More information about the Python-list mailing list