Bug 1256573 - Remove the @advanced primitive. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Sun, 27 Mar 2016 11:44:26 +0900
changeset 290993 09c22809d1dccf9604f585fd57b07a797826fb68
parent 290992 f4e24db79431e447e3f6b2758ec6dba4dca817c2
child 290994 26a63e35fb25be588548f81e6067a24674e5c3a3
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1256573
milestone48.0a1
Bug 1256573 - Remove the @advanced primitive. r=nalexander
python/mozbuild/mozbuild/configure/__init__.py
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -53,29 +53,28 @@ def forbidden_import(*args, **kwargs):
     raise ImportError('Importing modules is forbidden')
 
 
 class ConfigureSandbox(dict):
     """Represents a sandbox for executing Python code for build configuration.
     This is a different kind of sandboxing than the one used for moz.build
     processing.
 
-    The sandbox has 9 primitives:
+    The sandbox has 8 primitives:
     - option
     - depends
     - template
     - imports
-    - advanced
     - include
     - set_config
     - set_define
     - imply_option
 
     `option`, `include`, `set_config`, `set_define` and `imply_option` are
-    functions. `depends`, `template`, `imports` and `advanced` are decorators.
+    functions. `depends`, `template`, and `imports` are decorators.
 
     These primitives are declared as name_impl methods to this class and
     the mapping name -> name_impl is done automatically in __getitem__.
 
     Additional primitives should be frowned upon to keep the sandbox itself as
     simple as possible. Instead, helpers should be created within the sandbox
     with the existing primitives.
 
@@ -385,18 +384,18 @@ class ConfigureSandbox(dict):
             if not isinstance(what, types.StringTypes):
                 raise TypeError("Unexpected type: '%s'" % type(what))
             self.exec_file(what)
 
     def template_impl(self, func):
         '''Implementation of @template.
         This function is a decorator. Template functions are called
         immediately. They are altered so that their global namespace exposes
-        a limited set of functions from os.path, as well as `advanced`,
-        `depends` and `option`.
+        a limited set of functions from os.path, as well as `depends` and
+        `option`.
         Templates allow to simplify repetitive constructs, or to implement
         helper decorators and somesuch.
         '''
         template, glob = self._prepare_function(func)
         glob.update(
             (k[:-len('_impl')], getattr(self, k))
             for k in dir(self) if k.endswith('_impl') and k != 'template_impl'
         )
@@ -422,23 +421,16 @@ class ConfigureSandbox(dict):
                     return wrap_template(ret)
                 return ret
             return wrapper
 
         wrapper = wrap_template(template)
         self._templates.add(wrapper)
         return wrapper
 
-    def advanced_impl(self, func):
-        '''Implementation of @advanced.
-        This function gives the decorated function access to the complete set
-        of builtins, allowing the import keyword as an expected side effect.
-        '''
-        return self.imports_impl(_import='__builtin__', _as='__builtins__')(func)
-
     RE_MODULE = re.compile('^[a-zA-Z0-9_\.]+$')
 
     def imports_impl(self, _import, _from=None, _as=None):
         '''Implementation of @imports.
         This decorator imports the given _import from the given _from module
         optionally under a different _as name.
         The options correspond to the various forms for the import builtin.
             @imports('sys')
@@ -603,17 +595,17 @@ class ConfigureSandbox(dict):
                 raise TypeError("Unexpected type: '%s'" % type(value))
 
             option = value.format(option)
             self._helper.add(option, 'implied')
             self._implied_options[option] = inspect.stack()[1], reason
 
     def _prepare_function(self, func):
         '''Alter the given function global namespace with the common ground
-        for @depends, @template and @advanced.
+        for @depends, and @template.
         '''
         if not inspect.isfunction(func):
             raise TypeError("Unexpected type: '%s'" % type(func))
         if func in self._prepared_functions:
             return func, func.func_globals
 
         glob = SandboxedGlobal(func.func_globals)
         glob.update(