New submission from markhuang3310 <markhuang3...@gmail.com>: Env: Windows 10 Python3.8.10 amd64
Desciption: I try to get output from a python program with a subprocess. The python program print a unicode character. ``` import subprocess import sys cmd = rf'''{sys.executable} -c "print('\u042f')"''' print('case 1') stdout, stderr = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=None).communicate() print('case 2') stdout, stderr = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate() print(stderr) ``` The issue is that: In case 1, I can see the "Я" (\u042f) form console. In case 2, I try to get the output from subprocess.Popen(command).communicate()[0], the python process fail with UnicodeEncodeError. Expected result: In case2, I should get stdout == b'\u042f' ---------- components: Windows files: test.py messages: 414919 nosy: markhuang3310, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: if a python program is execute by subprocess, the python program can't output unicode characters and raise UnicodeEncodeError type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file50667/test.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46988> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com