> I think you're on to something. There's an API to access the
> underlying (buffered) binary stream: sys.stdout.buffer. It's possible
> to create a new TextIOWrapper on top of that:
> 
> sys.stdout = io.TextIOWrapper(sys.stdout.buffer, "utf-8")

While it might be possible to switch an output stream that way, it's
fairly difficult to do that correctly for input, no? The wrapper
may have already read data from the underlying stream which have not
been given to the application. If you don't want to lose these
data, you either need to copy them over to the new stream, or unread
them from the underlying buffer. That's tricky as some of the data might
be in the codec.

Regards,
Martin
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to