Pierre Carbonnelle <[email protected]> added the comment:
As a work around, I had to use a temporary file (instead of a memory buffer):
print("outside:", sys.stdout.encoding)
with open("/tmp/log.txt", mode='w', encoding='utf-8') as buf:
with redirect_stdout(buf) as f:
print("inside: ", sys.stdout.encoding)
with open("/tmp/log.txt", mode='r', encoding='utf-8') as f:
print(f.read())
and get:
outside: utf-8
inside: utf-8
as expected.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44774>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com