'Internal helper function to create a derived context.'

def derived(self, locals=None):

    context = new_context(self.environment, self.name, {}, self.parent, True, None, locals)
    context.blocks.update(((k, list(v)) for (k, v) in self.blocks.iteritems()))
    return context
