Juan Luis Boya García added the comment:
Sorry for the late response, GMail's SPAM filter ate the replies.
The main issue is sys.stdout being opened as text instead of binary. This fact
is stated in the docs. http://docs.python.org/3/library/sys.html#sys.stdout
In any case, there are
New submission from Juan Luis Boya García:
Sometimes developers need to write text to stdout, and it's nice to have on the
fly Unicode to UTF-8 conversion (or what matches the platform), but sometimes
they also need to output binary blobs, like text encoded in other codifications
tha