Bug 1335873 - Check for .pyc's existence before deleting it in mach_bootstrap import hook, r=glandium
☠☠ backed out by 90ac7081a45f ☠ ☠
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 21 Feb 2017 11:08:44 -0500
changeset 374421 2873be3659a3841a44d652f2e84f25983c59c4fa
parent 374420 f35554b2951eec1f87f2f5439286a6fbbd10c8e7
child 374422 cc6aba2aa355f73059b774e25f6aca55a873a30a
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1335873
milestone54.0a1
Bug 1335873 - Check for .pyc's existence before deleting it in mach_bootstrap import hook, r=glandium This situation can happen if we attempt to import a module we know might not exist, for example: https://dxr.mozilla.org/mozilla-central/rev/d0462b0948e0b1147dcce615bddcc46379bdadb2/testing/mozbase/mozlog/mozlog/formatters/machformatter.py#9 MozReview-Commit-ID: CTg775kN72h
build/mach_bootstrap.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -403,17 +403,18 @@ class ImportHook(object):
         # loading, remove the .pyc/.pyo file, and reload the module.
         # Since we already loaded the .pyc/.pyo module, if it had side
         # effects, they will have happened already, and loading the module
         # with the same name, from another directory may have the same side
         # effects (or different ones). We assume it's not a problem for the
         # python modules under our source directory (either because it
         # doesn't happen or because it doesn't matter).
         if not os.path.exists(module.__file__[:-1]):
-            os.remove(module.__file__)
+            if os.path.exists(module.__file__):
+                os.remove(module.__file__)
             del sys.modules[module.__name__]
             module = self(name, globals, locals, fromlist, level)
 
         return module
 
 
 # Install our hook
 __builtin__.__import__ = ImportHook(__builtin__.__import__)