Patch related to the #3453

This commit is contained in:
Miroslav Stampar
2019-05-21 14:18:14 +02:00
parent ea4052ec65
commit 688150cf6c
4 changed files with 23 additions and 2 deletions

View File

@@ -101,11 +101,29 @@ def filterNone(values): # Cross-referenced function
def isListLike(value): # Cross-referenced function
raise NotImplementedError
def shellExec(cmd): # Cross-referenced function
raise NotImplementedError
def stdoutEncode(value):
value = value or ""
if IS_WIN and kb.get("codePage", -1) is None:
output = shellExec("chcp")
match = re.search(r": (\d{3,})", output or "")
if match:
try:
candidate = "cp%s" % match.group(1)
codecs.lookup(candidate)
except LookupError:
pass
else:
kb.codePage = candidate
kb.codePage = kb.codePage or ""
if isinstance(value, six.text_type) and PYVERSION < "3.6":
encoding = sys.stdout.encoding or UNICODE_ENCODING
encoding = kb.get("codePage") or sys.stdout.encoding or UNICODE_ENCODING
while True:
try: