Bug 1641242 - Handle difference in API of ImportError between py2 and py3 in artifact_commands.py r=catlee
authorRicky Stewart <rstewart@mozilla.com>
Thu, 28 May 2020 20:33:03 +0000
changeset 596593 68cf56d38bb44a2bf741e5169a00776ba359b24a
parent 596592 8e81ac79b2ba1dcb9d08d8ba2098a59900cc03f1
child 596594 4a1540970cae5d08ee4e93711a84deeff32c4a25
push id13186
push userffxbld-merge
push dateMon, 01 Jun 2020 09:52:46 +0000
treeherdermozilla-beta@3e7c70a1e4a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscatlee
bugs1641242
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1641242 - Handle difference in API of ImportError between py2 and py3 in artifact_commands.py r=catlee Differential Revision: https://phabricator.services.mozilla.com/D77337
python/mozbuild/mozbuild/artifact_commands.py
--- a/python/mozbuild/mozbuild/artifact_commands.py
+++ b/python/mozbuild/mozbuild/artifact_commands.py
@@ -438,17 +438,21 @@ class PackageFrontend(MachCommandBase):
                 }
             if record.unpack and not no_unpack:
                 # Try to unpack the file. If we get an exception importing
                 # zstandard when calling unpack_file, we can try installing
                 # zstandard locally and trying again
                 try:
                     unpack_file(local)
                 except ImportError as e:
-                    if e.name != "zstandard":
+                    # Need to do this branch while this code is still exercised
+                    # by Python 2.
+                    if six.PY3 and e.name != "zstandard":
+                        raise
+                    elif six.PY2 and e.message != 'No module named zstandard':
                         raise
                     self._ensure_zstd()
                     unpack_file(local)
                 os.unlink(local)
 
         if not downloaded:
             self.log(logging.ERROR, 'artifact', {}, 'Nothing to download')
             if files: