Bug 1257516 - Allow to assign Exceptions in the global scope. r?ted draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Mar 2016 20:02:31 +0900
changeset 344698 edfc845531ba258ccbde22c993786e2b8fe35a11
parent 344697 b3af64933052e4f61c878e467101c65901d2f71f
child 344699 e98313c5c848ee2ef7a9d10b1288ee03b1077bdb
push id13908
push userbmo:mh+mozilla@glandium.org
push dateFri, 25 Mar 2016 11:36:41 +0000
reviewersted
bugs1257516
milestone48.0a1
Bug 1257516 - Allow to assign Exceptions in the global scope. r?ted But do not advertise it too much.
python/mozbuild/mozbuild/configure/__init__.py
--- 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