diff options
author | Mats Wichmann <mats@linux.com> | 2020-04-07 16:04:24 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2020-04-07 16:04:24 (GMT) |
commit | 433c62479cc022ae7b07cf46a8c772cedae2842f (patch) | |
tree | 308ac8fdae394b7a60c40dddf9884eb9b831e6cf /src/engine/SCons | |
parent | a9eb4e07328ac11b912c7393ca500df8b00ce49c (diff) | |
download | SCons-433c62479cc022ae7b07cf46a8c772cedae2842f.zip SCons-433c62479cc022ae7b07cf46a8c772cedae2842f.tar.gz SCons-433c62479cc022ae7b07cf46a8c772cedae2842f.tar.bz2 |
[PR #3576] workaroud "oem" coding not on Py3.5
Use a Windows API to fetch the console output code page
if Python < 3.6, where the encoding name "oem" is not yet defined
(this was the original proposal in issue #3572)
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'src/engine/SCons')
-rw-r--r-- | src/engine/SCons/Tool/MSCommon/common.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index b90c25a..b2b5de9 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -249,14 +249,21 @@ def get_output(vcbat, args=None, env=None): # Ongoing problems getting non-corrupted text led to this # changing to "oem" from "mbcs" - the scripts run presumably # attached to a console, so some particular rules apply. + # Unfortunately, "oem" not defined in Python 3.5, so get another way + if sys.version_info.major == 3 and sys.version_info.minor < 6: + from ctypes import windll + + OEM = "cp{}".format(windll.kernel32.GetConsoleOutputCP()) + else: + OEM = "oem" if stderr: # TODO: find something better to do with stderr; # this at least prevents errors from getting swallowed. - sys.stderr.write(stderr.decode("oem")) + sys.stderr.write(stderr.decode(OEM)) if popen.wait() != 0: - raise IOError(stderr.decode("oem")) + raise IOError(stderr.decode(OEM)) - return stdout.decode("oem") + return stdout.decode(OEM) KEEPLIST = ( |