Bug 1335873 - Check for .pyc's existence before deleting it in mach_bootstrap import hook, r=glandium
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 21 Feb 2017 11:08:44 -0500
changeset 345469 d23c02b2fed0cb0497a596f1f720f53dbbdc2f24
parent 345468 290234233d6bee7dc87db5f59f076f2c039e412d
child 345470 1d8bb95f9eb0b50f1cb3b77dc9a4c7ca480facc3
push id31437
push usercbook@mozilla.com
push dateThu, 02 Mar 2017 13:00:04 +0000
treeherdermozilla-central@180a160ae22a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1335873
milestone54.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 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__)