[Python-ideas] Replacing the standard IO streams (was Re: changing sys.stdout encoding)

Paul Moore p.f.moore at gmail.com
Mon Jun 11 10:06:42 CEST 2012


On 11 June 2012 07:16, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> MRAB writes:
>
>  > That's actually Python 3.1. From Python 3.2 it's slightly different,
>  > but still not quite right:
>  >
>  > Python 3.1:     "hello\r\nhello\r\r\n"
>  > Python 3.2:     "hello\nhello\r\n"
>  > Python 3.3.0a4: "hello\nhello\r\n"
>  >
>  > All on Windows.
>
> <stifle o="self"/>
>
> Hm.  Maybe it's that port's implementation of universal newlines or
> something like that?  What happens if you use an explicit "end="
> argument?  (I don't have a Python 3 to check on Windows easily
> available.)

Explicit end= makes no difference to the behaviour. In fact, a minimal
test suggests that universal newline mode is not enabled on Windows in
Python 3. That's a regression from 2.x. See below.

D:\Data>py -3 -c "print('x')" | od -c
0000000   x  \n
0000002

D:\Data>py -2 -c "print('x')" | od -c
0000000   x  \r  \n
0000003

D:\Data>py -3 -V
Python 3.2.2

D:\Data>py -2 -V
Python 2.7.2

Paul.



More information about the Python-ideas mailing list