From 1c6231c29ca42a912ff5d23485765d05106eeb6f Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 27 Nov 2015 21:01:28 +0900 Subject: [PATCH] Bug 1229241 - Allow moz.build special variables to be set, as long as the value is not modified. r=gps This will allow a new kind of special variable where it is possible to do FOO += ['bar'] All the current special variables are either strings (for which __setitem__ would be called with a different string object), or a read-only dict (which doesn't allow modifications). --- python/mozbuild/mozbuild/frontend/reader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py index 4eb597d3b634..cf532678656a 100644 --- a/python/mozbuild/mozbuild/frontend/reader.py +++ b/python/mozbuild/mozbuild/frontend/reader.py @@ -219,6 +219,8 @@ class MozbuildSandbox(Sandbox): return Sandbox.__contains__(self, key) def __setitem__(self, key, value): + if key in self.special_variables and value is self[key]: + return if key in self.special_variables or key in self.functions or key in self.subcontext_types: raise KeyError('Cannot set "%s" because it is a reserved keyword' % key)