mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1857512: use utf-8
encoding for mozversioncontrol VCS commands r=zeid
`mozversioncontrol` runs currently use `universal_newlines`, which is an alias for `text`. This forces the command output file object to be opened in text mode using the platform's default encoding. On Windows the default encoding is usually a single-byte encoding such as `cp-1252`, which can cause issues when parsing patches that include multi-byte sequences. Add an `encoding` option to `_run` with `utf-8` as the default option and change the `check_output` call to use it. Callers can revert to the previous behaviour quite easily by setting `encoding=None` if necessary. Differential Revision: https://phabricator.services.mozilla.com/D190710
This commit is contained in:
parent
fb2f4c03cb
commit
02b9156f7c
@ -95,7 +95,7 @@ class Repository(object):
|
||||
def __exit__(self, exc_type, exc_value, exc_tb):
|
||||
pass
|
||||
|
||||
def _run(self, *args, **runargs):
|
||||
def _run(self, *args, encoding="utf-8", **runargs):
|
||||
return_codes = runargs.get("return_codes", [])
|
||||
|
||||
cmd = (str(self._tool),) + args
|
||||
@ -108,7 +108,10 @@ class Repository(object):
|
||||
else:
|
||||
try:
|
||||
return subprocess.check_output(
|
||||
cmd, cwd=self.path, env=self._env, universal_newlines=True
|
||||
cmd,
|
||||
cwd=self.path,
|
||||
env=self._env,
|
||||
encoding=encoding,
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode in return_codes:
|
||||
|
Loading…
Reference in New Issue
Block a user