[Python-ideas] changing sys.stdout encoding

Victor Stinner 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
the issue.


 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>
> wrote:
> > 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?
> https://gist.github.com/3280063
> --
> INADA Naoki  <songofacandy at gmail.com>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120807/82daf475/attachment.html>

More information about the Python-ideas mailing list