Bug 1257516 - Allow to assign Exceptions in the global scope. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Mar 2016 20:02:31 +0900
changeset 290979 9bcbc8d381e45de860c4037af1936c4fe4911030
parent 290978 062e0b17553ccac075a0cab36f012d9633a64665
child 290980 7640e60c144a8a954ed06a168d1bc7c2550cf3ef
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)
Bug 1257516 - Allow to assign Exceptions in the global scope. r=ted But do not advertise it too much.
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -227,17 +227,18 @@ class ConfigureSandbox(dict):
         return super(ConfigureSandbox, self).__getitem__(key)
     def __setitem__(self, key, value):
         if (key in self.BUILTINS or key == '__builtins__' or
                 hasattr(self, '%s_impl' % key)):
             raise KeyError('Cannot reassign builtins')
         if (not isinstance(value, DummyFunction) and
-                value not in self._templates):
+                value not in self._templates and
+                not issubclass(value, Exception)):
             raise KeyError('Cannot assign `%s` because it is neither a '
                            '@depends nor a @template' % key)
         return super(ConfigureSandbox, self).__setitem__(key, value)
     def _resolve(self, arg, need_help_dependency=True):
         if isinstance(arg, DummyFunction):
             assert arg in self._depends