Why do you need to force the UTF-8 encoding? Your locale is not correctly configured?
It's better to set PYTHONIOENCODING rather than replacing sys.stdout/stderr at runtime. There is an open issue to add a TextIOWrapper.set_encoding() method: http://bugs.python.org/issue15216 Victor -- https://mail.python.org/mailman/listinfo/python-list