Skip to content

Commit 84abfbf

Browse files
committed
Use CP_ACP as fallback encoding for stdout.
sys.stdout.encoding and sys.getdefaultencoding() both are utf-8 since Python 3.6. See https://www.python.org/dev/peps/pep-0528/
1 parent 97a6490 commit 84abfbf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CheckOption.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
import subprocess
55
import string
66
import xml.dom.minidom
7+
import ctypes
8+
9+
CP_ACP = 'cp' + str(ctypes.windll.kernel32.GetACP())
710

811
def decode_stdout(doc):
912
if not doc:
1013
return ''
1114
try:
1215
return doc.decode('utf-8')
1316
except UnicodeDecodeError:
14-
try:
15-
return doc.decode(sys.stdout.encoding)
16-
except UnicodeDecodeError:
17-
return doc.decode(sys.getdefaultencoding())
17+
return doc.decode(CP_ACP)
1818

1919
def get_clang_cl_help(filename, saveLog=True):
2020
with subprocess.Popen([filename, '/?'], stdout=subprocess.PIPE) as proc:

0 commit comments

Comments
 (0)