Bug 1378410 - 2a. Expose `set` to moz.build sandbox; r=gps
authorJim Chen <nchen@mozilla.com>
Fri, 01 Sep 2017 14:02:30 -0400
changeset 378363 704e761343e0403262220a5dc112b4a3bacce890
parent 378362 1bf78591e4542c69372da02898950e3304e935b5
child 378364 8e135c63527f0e0af349d3fd8a5bb1ad0ba3cb8a
push id32428
push userarchaeopteryx@coole-files.de
push dateSat, 02 Sep 2017 08:52:28 +0000
treeherdermozilla-central@b01a7e57425b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1378410
milestone57.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 1378410 - 2a. Expose `set` to moz.build sandbox; r=gps To construct an empty set, we need to use the `set()` notation. In order to do that, we need to expose `set` to the moz.build sandbox. MozReview-Commit-ID: DMyKnF0FEx2
build/docs/mozbuild-files.rst
python/mozbuild/mozbuild/frontend/sandbox.py
--- a/build/docs/mozbuild-files.rst
+++ b/build/docs/mozbuild-files.rst
@@ -29,20 +29,20 @@ The following properties make execution 
 
 1. The execution environment exposes a limited subset of Python.
 2. There is a special set of global symbols and an enforced naming
    convention of symbols.
 3. Some symbols are inherited from previously-executed ``moz.build``
    files.
 
 The limited subset of Python is actually an extremely limited subset.
-Only a few symbols from ``__builtins__`` are exposed. These include
-``True``, ``False``, and ``None``. Global functions like ``import``,
-``print``, and ``open`` aren't available. Without these, ``moz.build``
-files can do very little. *This is by design*.
+Only a few symbols from ``__builtin__`` are exposed. These include
+``True``, ``False``, ``None``, ``sorted``, ``int``, and ``set``. Global
+functions like ``import``, ``print``, and ``open`` aren't available.
+Without these, ``moz.build`` files can do very little. *This is by design*.
 
 The execution sandbox treats all ``UPPERCASE`` variables specially. Any
 ``UPPERCASE`` variable must be known to the sandbox before the script
 executes. Any attempt to read or write to an unknown ``UPPERCASE``
 variable will result in an exception being raised. Furthermore, the
 types of all ``UPPERCASE`` variables is strictly enforced. Attempts to
 assign an incompatible type to an ``UPPERCASE`` variable will result in
 an exception being raised.
--- a/python/mozbuild/mozbuild/frontend/sandbox.py
+++ b/python/mozbuild/mozbuild/frontend/sandbox.py
@@ -105,16 +105,17 @@ class Sandbox(dict):
     # The default set of builtins.
     BUILTINS = ReadOnlyDict({
         # Only real Python built-ins should go here.
         'None': None,
         'False': False,
         'True': True,
         'sorted': alphabetical_sorted,
         'int': int,
+        'set': set,
     })
 
     def __init__(self, context, builtins=None, finder=default_finder):
         """Initialize a Sandbox ready for execution.
         """
         self._builtins = builtins or self.BUILTINS
         dict.__setitem__(self, '__builtins__', self._builtins)