return self.generic_visit(node, context)
for filter in reversed(node.filters):
# XXX: call filters with arguments
- x = self.environment.filters[filter.name](self.environment, x)
+ x = self.environment.filters[filter.name](x)
# XXX: don't optimize context dependent filters
- return nodes.Const(x)
+ try:
+ return nodes.Const.from_untrusted(x, lineno=node.lineno)
+ except nodes.Impossible:
+ return self.generic_visit(node)
def visit_For(self, node, context):
"""Loop unrolling for iterable constant values."""