Eryk Sun <eryk...@gmail.com> added the comment:

The interpreter uses the system ANSI codepage for non-console files. In your 
case this is codepage 1252. In my current setup I can't reproduce this issue 
since I'm using the new (beta) support in Windows 10 to configure the ANSI 
codepage as UTF-8 (65001).

You can force standard I/O to use UTF-8 by setting the environment variable 
PYTHONIOENCODING. Also, if you want the CompletedProcess stdout decoded as 
text, in 3.6+ you can pass the parameter `encoding='utf-8'`. For example:

    environ = os.environ.copy()
    environ['PYTHONIOENCODING'] = 'utf-8'
    p = subprocess.run([sys.executable, *args], stdout=subprocess.PIPE, 
stderr=subprocess.STDOUT, env=environ, encoding='utf-8')
    print(p.stdout)

----------
nosy: +eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

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

Reply via email to