Bug 1256573 - Remove the @advanced primitive. r?nalexander draft
authorMike Hommey <mh+mozilla@glandium.org>
Sun, 27 Mar 2016 11:44:26 +0900
changeset 345024 67514b1a7f0f164ff3f152989583b8534570060a
parent 345023 a0d6f3040da8e5a8783392dc6692a851631a3b97
child 345025 d5534df8ca17bea71780ea162ca9480da32de072
push id13997
push userbmo:mh+mozilla@glandium.org
push dateSun, 27 Mar 2016 22:55:22 +0000
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(