Bug 1414060 - Give json.dump the correct encoding. r?Build draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sat, 04 Nov 2017 10:24:13 +0900
changeset 693071 c16c09c1e950bcee07924e72c1a11a4f7bf75011
parent 693070 70bd1d57f7807484c15ebe9c54aa9df5f063449b
child 738942 88295af19c730509db3f42f0e7063d2e79f0c17e
push id87699
push userVYV03354@nifty.ne.jp
push dateSat, 04 Nov 2017 02:18:39 +0000
reviewersBuild
bugs1414060
milestone58.0a1
Bug 1414060 - Give json.dump the correct encoding. r?Build MozReview-Commit-ID: 6gzQq0kUYW0
python/mozbuild/mozbuild/backend/configenvironment.py
--- a/python/mozbuild/mozbuild/backend/configenvironment.py
+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
@@ -234,19 +234,20 @@ class PartialConfigDict(object):
         try:
             with open(self._config_track) as fh:
                 existing_files.update(fh.read().splitlines())
         except IOError:
             pass
         return existing_files
 
     def _write_file(self, key, value):
+        encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
         filename = mozpath.join(self._datadir, key)
         with FileAvoidWrite(filename) as fh:
-            json.dump(value, fh, indent=4)
+            json.dump(value, fh, indent=4, encoding=encoding)
         return filename
 
     def _fill_group(self, values):
         # Clear out any cached values. This is mostly for tests that will check
         # the environment, write out a new set of variables, and then check the
         # environment again. Normally only configure ends up calling this
         # function, and other consumers create their own
         # PartialConfigEnvironments in new python processes.