Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions utils/gyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ def tokenGenerator(self, baseTokens):
if (kind == 'gybBlockOpen'):
# Absorb any '}% <optional-comment> \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'
Expand Down Expand Up @@ -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

Expand Down