[Python-3000] Proposed new language for newline parameter to TextIOBase
Guido van Rossum
guido at python.org
Wed Aug 15 22:17:15 CEST 2007
On 8/15/07, Adam Olsen <rhamph at gmail.com> wrote:
> On 8/14/07, Guido van Rossum <guido at python.org> wrote:
> > (2) newline='': input with untranslated universal newlines mode; lines
> > may end in \r, \n, or \r\n, and these are returned untranslated.
>
> Caveat: this mode cannot be supported by sockets. When reading a lone
> \r you need to peek ahead to ensure the next character is not a \n,
> but for sockets that may block indefinitely.
It depends on what you want. In general *any* read from a socket may
block indefinitely. If the protocol requires turning around at \r *or*
\r\n I'd say the protocol is insane.
> I don't expect sockets to use the file API by default, but there's
> enough overlap (named pipes?) that limitations like this should be
> well documented (and if possible, produce an explicit error!)
Why do you want it to produce an error? Who says I don't know what I'm
doing when I request that mode?
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list