Bug 1362872 - Use mbcs encoding for vswhere output. r?gps draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 08 May 2017 15:31:44 +0900
changeset 574554 03ecca535c182083fcd6dc98e3479a4c58dfa784
parent 573891 c3e5497cff1c995821b1c9320fa71f1ef9a8c30e
child 627639 54f7df209d776eb40b8aa568a95428dcc4229884
push id57753
push userm_kato@ga2.so-net.ne.jp
push dateTue, 09 May 2017 02:58:20 +0000
reviewersgps
bugs1362872
milestone55.0a1
Bug 1362872 - Use mbcs encoding for vswhere output. r?gps We add vswhere.exe to support VS2017. But the description output of this command is localized, so it causes UnicodeDecodeError. So we should use 'mbcs' encoding for this output on Windows platform. And for minor languages, we should also use replace to avoid decode error. test_toolchain_configure.py calls vc_compiler_path without correct host.kernel, so we should check current python platform. MozReview-Commit-ID: AkryAzrgSzs
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -408,19 +408,21 @@ def check_compiler(compiler, language, t
         target_endianness=info.endianness,
         flags=flags,
     )
 
 
 @imports(_from='__builtin__', _import='open')
 @imports('json')
 @imports('subprocess')
+@imports('sys')
 def get_vc_paths(topsrcdir):
     def vswhere(args):
-        return json.loads(subprocess.check_output([os.path.join(topsrcdir, 'build/win32/vswhere.exe'), '-format', 'json'] + args))
+        encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
+        return json.loads(subprocess.check_output([os.path.join(topsrcdir, 'build/win32/vswhere.exe'), '-format', 'json'] + args).decode(encoding, 'replace'))
 
     # Can't pass -requires with -legacy, so query each separately.
     # Legacy versions first (VS2015)
     for install in vswhere(['-legacy', '-version', '[14.0,15.0)']):
         version = Version(install['installationVersion'])
         # Skip anything older than VS2015.
         if version < '14':
             continue