<p>The write buffer can be flushed, so I don't see the problem of changing the encoding of stdout and stderr (except potential mojibake).</p>
<p>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).</p>
<p>I wrote a Python implementation of set_encoding, see my patch attached to the issue.</p>
<p><a href="http://bugs.python.org/15216">http://bugs.python.org/15216</a></p>
<p>Victor<br>
</p>
<div class="gmail_quote">Le 7 août 2012 02:52, "INADA Naoki" <<a href="mailto:songofacandy@gmail.com" target="_blank">songofacandy@gmail.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

On Wed, Jun 13, 2012 at 5:35 PM, Stephen J. Turnbull <<a href="mailto:stephen@xemacs.org" target="_blank">stephen@xemacs.org</a>> wrote:<br>
> Guido van Rossum writes:<br>
><br>
>  > I'm not sure about a name, but it might well be called set_encoding().<br>
><br>
> I would still prefer "initialize_encoding" or something like that, but<br>
> the main thing I was worried about was a "consenting adults" function<br>
> that shouldn't be called after I/O, but *could* be.<br>
<br>
I still don't understand why Python can't support using it after I/O.<br>
Is this code wrong?<br>
<a href="https://gist.github.com/3280063" target="_blank">https://gist.github.com/3280063</a><br>
<br>
--<br>
INADA Naoki  <<a href="mailto:songofacandy@gmail.com" target="_blank">songofacandy@gmail.com</a>><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</blockquote></div>