diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 6b9c786fa..36f55a907 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -595,7 +595,9 @@ def function_scoping(self, node, frame, children=None, # variables that are undeclared (accessed before declaration) and # declared locally *and* part of an outside scope raise a template # assertion error. Reason: we can't generate reasonable code from - # it without aliasing all the variables. XXX: alias them ^^ + # it without aliasing all the variables. + # this could be fixed in Python 3 where we have the nonlocal + # keyword or if we switch to bytecode generation overriden_closure_vars = ( func_frame.identifiers.undeclared & func_frame.identifiers.declared & diff --git a/tests/test_old_bugs.py b/tests/test_old_bugs.py index a30c90922..687d962e1 100644 --- a/tests/test_old_bugs.py +++ b/tests/test_old_bugs.py @@ -33,3 +33,23 @@ def test_extends_output_bugs(): def test_urlize_filter_escaping(env): tmpl = env.from_string('{{ "http://www.example.org/http://www.example.org/<foo' + + +def test_loop_call_loop(env): + tmpl = env.from_string(''' + + {% macro test() %} + {{ caller() }} + {% endmacro %} + + {% for num1 in range(5) %} + {% call test() %} + {% for num2 in range(10) %} + {{ loop.index }} + {% endfor %} + {% endcall %} + {% endfor %} + + ''') + + assert tmpl.render() == ''