Bug 1362872 - Use mbcs encoding for vswhere output. r=gps, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 08 May 2017 15:31:44 +0900
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357483 6110ea38bcee80c8089137bb6ea23cc3ecdd5cc3
parent 357482 da7709c18e6682fca8db48c207a8aeff77f6c714
child 357484 1315c3bb26e1af5830566f7137ed44a9fa5cf6d1
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, IanN
bugs1362872
milestone52.9.1
Bug 1362872 - Use mbcs encoding for vswhere output. r=gps, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH 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.
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -392,19 +392,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