Pierre Carbonnelle <pierre.carbonne...@gmail.com> added the comment:

I expect sys.stdout to have utf-8 encoding inside the redirect because the 
buffer accepts unicode code points (not bytes), just as it does outside of the 
redirect.  In other words, I expect the 'encoding' attribute of sys.stdout to 
have the same value inside and outside this redirect.

It so happens that sys.stdout is an io.StringIO() object inside the redirect.  
The getvalue() method on this object returns a string (not a bytes), i.e. a 
sequence of unicode points.

StringIO inherits from TextIOBase, which has an 'encoding' attribute.  For some 
reason, the encoding of a StringIO object is None, which is inconsistent with 
its semantics: it should be 'uft-8'.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44774>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to