[issue44774] incorrect sys.stdout.encoding within a io.StringIO buffer

2021-07-30 Thread Pierre Carbonnelle
New submission from Pierre Carbonnelle : The following code print("outside:", sys.stdout.encoding) with redirect_stdout(io.StringIO()) as f: print("inside: ", sys.stdout.encoding) print(f.getvalue()) yields: outside: utf-8 inside: None B

[issue44774] incorrect sys.stdout.encoding within a io.StringIO buffer

2021-07-30 Thread Pierre Carbonnelle
Pierre Carbonnelle 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

[issue44774] incorrect sys.stdout.encoding within a io.StringIO buffer

2021-07-30 Thread Pierre Carbonnelle
Pierre Carbonnelle 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_std

[issue44774] incorrect sys.stdout.encoding within a io.StringIO buffer

2021-07-30 Thread Pierre Carbonnelle
Pierre Carbonnelle added the comment: I can live with the workaround, so, you can close the issue if you wish. As you say, maybe it's an issue with z3. Thank you for your time. -- ___ Python tracker <https://bugs.python.org/is