[issue21364] Documentation Recommends Broken Pattern
Antoine Pitrou
report at bugs.python.org
Thu May 15 23:50:57 CEST 2014
Antoine Pitrou added the comment:
> The same situations people wrapped streams before on python 2:
>
> * code.py users. Werkzeug's traceback system implements a remote python
> shell through it.
> * any system that wants to unittest shell scripts on a high level.
> * any system that wants to execute arbitrary python code and then
> capture whatever output it did. This is for instance what I see
> Sphinx users frequently do (or doctests)
I see, I misunderstood you. You actually want to get back the bytes
output of e.g. stdout, right?
You could indeed use a TextIOWrapper wrapping a BytesIO object. Or of
course another possibility is to do the encoding yourself, e.g.
sys.stdout.getvalue().encode('utf-8', 'surrogateescape').
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21364>
_______________________________________
More information about the Python-bugs-list
mailing list