diff --git a/utils/gyb.py b/utils/gyb.py index 91af3a4e8c9b0..b26d68f6329e9 100755 --- a/utils/gyb.py +++ b/utils/gyb.py @@ -466,7 +466,8 @@ def tokenGenerator(self, baseTokens): if (kind == 'gybBlockOpen'): # Absorb any '}% \n' m2 = gybBlockClose.match(self.template, closePos) - assert m2, "Invalid block closure" # FIXME: need proper error handling here. + if not m2: + raise ValueError("Invalid block closure") nextPos = m2.end(0) else: assert kind == 'substitutionOpen' @@ -656,7 +657,9 @@ def execute(self, context): # Execute the code with our __children__ in scope context.localBindings['__children__'] = self.children result = eval(self.code, context.localBindings) - assert context.localBindings['__children__'] is self.children + + if context.localBindings['__children__'] is not self.children: + raise ValueError("The code is not allowed to mutate __children__") # Restore the bindings context.localBindings['__children__'] = saveChildren