[Python-ideas] changing sys.stdout encoding
victor.stinner at gmail.com
Tue Aug 7 12:20:30 CEST 2012
The write buffer can be flushed, so I don't see the problem of changing the
encoding of stdout and stderr (except potential mojibake).
For stdin, TextIOWrapper has a readahead algorithm, so changing the
encoding may seek backward. It cannot be done if stdin is not seekable (ex:
if stdin is a pipe).
I wrote a Python implementation of set_encoding, see my patch attached to
Le 7 août 2012 02:52, "INADA Naoki" <songofacandy at gmail.com> a écrit :
> On Wed, Jun 13, 2012 at 5:35 PM, Stephen J. Turnbull <stephen at xemacs.org>
> > Guido van Rossum writes:
> > > I'm not sure about a name, but it might well be called set_encoding().
> > I would still prefer "initialize_encoding" or something like that, but
> > the main thing I was worried about was a "consenting adults" function
> > that shouldn't be called after I/O, but *could* be.
> I still don't understand why Python can't support using it after I/O.
> Is this code wrong?
> INADA Naoki <songofacandy at gmail.com>
> Python-ideas mailing list
> Python-ideas at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas