Skip to content

Commit

Permalink
Added testcase for a bug
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
mitsuhiko committed Mar 17, 2009
1 parent d416a97 commit 02b42a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jinja2/compiler.py
Expand Up @@ -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 &
Expand Down
20 changes: 20 additions & 0 deletions tests/test_old_bugs.py
Expand Up @@ -33,3 +33,23 @@ def test_extends_output_bugs():
def test_urlize_filter_escaping(env):
tmpl = env.from_string('{{ "http://www.example.org/<foo"|urlize }}')
assert tmpl.render() == '<a href="http://www.example.org/&lt;foo">http://www.example.org/&lt;foo</a>'


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() == ''

0 comments on commit 02b42a8

Please sign in to comment.