Bug 1264482 - Fake an arbitrary __name__ in sandboxed global. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 06 Apr 2016 09:35:40 +0900
changeset 331686 f464affb29486b7f718300c0b5680c84937b1373
parent 331685 adf8fb3e8d48a4704bde59394c6c51a6ff7e40be
child 331687 bb77bbe1fbd702545e71867dec66651d30b69526
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1264482
milestone48.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 1264482 - Fake an arbitrary __name__ in sandboxed global. r=ted
build/moz.configure/checks.configure
python/mozbuild/mozbuild/configure/__init__.py
--- a/build/moz.configure/checks.configure
+++ b/build/moz.configure/checks.configure
@@ -8,17 +8,16 @@
 # ==============================================================
 
 # Declare some exceptions. This is cumbersome, but since we shouldn't need a
 # lot of them, let's stack them all here. When adding a new one, put it in the
 # _declare_exceptions template, and add it to the return statement. Then
 # destructure in the assignment below the function declaration.
 @template
 @imports(_from='__builtin__', _import='Exception')
-@imports(_from='__builtin__', _import='__name__')
 def _declare_exceptions():
     class FatalCheckError(Exception):
         '''An exception to throw from a function decorated with @checking.
         It will result in calling die() with the given message.
         Debugging messages emitted from the decorated function will also be
         printed out.'''
     return (FatalCheckError,)
 
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -698,16 +698,17 @@ class ConfigureSandbox(dict):
         glob = SandboxedGlobal(
             (k, v) for k, v in func.func_globals.iteritems()
             if (inspect.isfunction(v) and v not in self._templates) or (
                 inspect.isclass(v) and issubclass(v, Exception))
         )
         glob.update(
             __builtins__=self.BUILTINS,
             __file__=self._paths[-1] if self._paths else '',
+            __name__=self._paths[-1] if self._paths else '',
             os=self.OS,
             log=self.log_impl,
         )
 
         # The execution model in the sandbox doesn't guarantee the execution
         # order will always be the same for a given function, and if it uses
         # variables from a closure that are changed after the function is
         # declared, depending when the function is executed, the value of the