- Added back support for custom contexts that override the old `resolve`
method since it was hard for people to spot that this could cause a
regression.
+- Correctly use the buffer for the else block of for loops. This caused
+ invalid syntax errors to be caused on 2.x and completely wrong behavior
+ on Python 3 (#669)
Version 2.9.4
-------------
self.indent()
self.buffer(loop_frame)
+ # Use the same buffer for the else frame
+ else_frame.buffer = loop_frame.buffer
+
# make sure the loop variable is a special one and raise a template
# assertion error if a loop tries to write to loop
if extended_loop:
assert x.resolve_or_missing('foo') == 42
assert x.resolve_or_missing('bar') == 23
assert x.resolve_or_missing('baz') is missing
+
+ def test_recursive_loop_bug(self, env):
+ tmpl = env.from_string('''
+ {%- for value in values recursive %}1{% else %}0{% endfor -%}
+ ''')
+ assert tmpl.render(values=[]) == '0'