Skip to content
Myr

Added ugly workaround for a loop bug.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent b4da9be · Browse files · 2 files+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−1 removed

  • tests:+1 added−1 removed
  • other:+9 added−0 removed

2 files+10 added−1 removed

modified:jinja2/compiler.py+9 added
645 unmodified lines
646 frame = self.function_scoping(node, frame, children)647 # macros are delayed, they never require output checks648 frame.require_output_check = False649 args = frame.arguments650 # XXX: this is an ugly fix for the loop nesting bug651 # (tests.test_old_bugs.test_loop_call_bug). This works around652 # a identifier nesting problem we have in general. It's just more653 # likely to happen in loops which is why we work around it. The654 # real solution would be "nonlocal" all the identifiers that are655 # leaking into a new python frame and might be used both unassigned656 # and assigned.657 if 'loop' in frame.identifiers.declared:658 args.append('l_loop=l_loop')659 self.writeline('def macro(%s):' % ', '.join(args), node)660 self.indent()661 self.buffer(frame)662 self.pull_locals(frame)
845 unmodified lines
modified:tests/test_old_bugs.py+1 added-1 removed
54 unmodified lines
55 {% endfor %}5657 ''')5859 assert tmpl.render() == ''59 assert tmpl.render().split() == map(unicode, range(1, 11)) * 5606162def test_weird_inline_comment():63 env = Environment(line_statement_prefix='%')
8 unmodified lines