diff --git a/mach b/mach index 1a4869ada6605..a849560367eba 100755 --- a/mach +++ b/mach @@ -14,7 +14,6 @@ py2commands=" analyze android android-emulator - artifact awsy-test browsertime cargo diff --git a/python/mozbuild/mozbuild/action/tooltool.py b/python/mozbuild/mozbuild/action/tooltool.py index 9d966f7420a9b..cfd692da0cbd8 100755 --- a/python/mozbuild/mozbuild/action/tooltool.py +++ b/python/mozbuild/mozbuild/action/tooltool.py @@ -705,7 +705,7 @@ def open_manifest(manifest_file): """I know how to take a filename and load it into a Manifest object""" if os.path.exists(manifest_file): manifest = Manifest() - with open(manifest_file, "rb") as f: + with open(manifest_file, "r" if PY3 else "rb") as f: manifest.load(f) log.debug("loaded manifest from file '%s'" % manifest_file) return manifest diff --git a/python/mozbuild/mozbuild/artifact_cache.py b/python/mozbuild/mozbuild/artifact_cache.py index 14775c28c0309..7230e86542750 100644 --- a/python/mozbuild/mozbuild/artifact_cache.py +++ b/python/mozbuild/mozbuild/artifact_cache.py @@ -162,7 +162,7 @@ def fetch(self, url, force=False): if len(fname) not in (32, 40, 56, 64, 96, 128): raise TypeError() binascii.unhexlify(fname) - except TypeError: + except (TypeError, binascii.Error): # We download to a temporary name like HASH[:16]-basename to # differentiate among URLs with the same basenames. We used to then # extract the build ID from the downloaded artifact and use it to make a diff --git a/python/mozbuild/mozbuild/artifact_commands.py b/python/mozbuild/mozbuild/artifact_commands.py index a161c90edbc8e..3488a3429af1d 100644 --- a/python/mozbuild/mozbuild/artifact_commands.py +++ b/python/mozbuild/mozbuild/artifact_commands.py @@ -412,7 +412,7 @@ def __init__(self, task_id, artifact_name): # Keep a sha256 of each downloaded file, for the chain-of-trust # validation. if artifact_manifest is not None: - with open(local) as fh: + with open(local, 'rb') as fh: h = hashlib.sha256() while True: data = fh.read(1024 * 1024) diff --git a/python/mozbuild/mozbuild/artifacts.py b/python/mozbuild/mozbuild/artifacts.py index c9cf28640fc2f..edb68010617f4 100644 --- a/python/mozbuild/mozbuild/artifacts.py +++ b/python/mozbuild/mozbuild/artifacts.py @@ -897,6 +897,7 @@ def run_hg(self, *args, **kwargs): env = kwargs.get('env', {}) env['HGPLAIN'] = '1' kwargs['env'] = ensure_subprocess_env(env) + kwargs['universal_newlines'] = True return subprocess.check_output([self._hg] + list(args), **kwargs) @@ -979,11 +980,11 @@ def _get_hg_revisions_from_git(self): self._git, 'rev-list', '--topo-order', '--max-count={num}'.format(num=NUM_REVISIONS_TO_QUERY), 'HEAD', - ], cwd=self._topsrcdir) + ], universal_newlines=True, cwd=self._topsrcdir) hg_hash_list = subprocess.check_output([ self._git, 'cinnabar', 'git2hg' - ] + rev_list.splitlines(), cwd=self._topsrcdir) + ] + rev_list.splitlines(), universal_newlines=True, cwd=self._topsrcdir) zeroes = "0" * 40 @@ -1201,7 +1202,8 @@ def install_from_revset(self, revset, distdir): elif self._git: revset = subprocess.check_output([ self._git, 'rev-parse', '%s^{commit}' % revset], - stderr=open(os.devnull, 'w'), cwd=self._topsrcdir).strip() + stderr=open(os.devnull, 'w'), universal_newlines=True, + cwd=self._topsrcdir).strip() else: # Fallback to the exception handling case from both hg and git raise subprocess.CalledProcessError() @@ -1215,7 +1217,8 @@ def install_from_revset(self, revset, distdir): if revision is None and self._git: revision = subprocess.check_output( - [self._git, 'cinnabar', 'git2hg', revset], cwd=self._topsrcdir).strip() + [self._git, 'cinnabar', 'git2hg', revset], universal_newlines=True, + cwd=self._topsrcdir).strip() if revision == "0" * 40 or revision is None: raise ValueError('revision specification must resolve to a commit known to hg')