Skip to content
Myr

Resolved bad code generation on toplevel ifs

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

This fixes #651

authored by Armin Ronacher · committed by Armin Ronacher · parent ef71801 · Browse files · 3 files+8 added−2 removed
This commit

State

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

Diff stats

3 files+8 added−2 removed

  • tests:+4 added−0 removed
  • other:+4 added−2 removed

3 files+8 added−2 removed

modified:jinja2/compiler.py+1 added-2 removed
365 unmodified lines
366 """Visit a list of nodes as block in a frame. If the current frame367 is no buffer a dummy ``if 0: yield None`` is written automatically.368 """369 try:370 if not nodes:371 self.writeline('pass')370 self.writeline('pass')371 for node in nodes:372 self.visit(node, frame)373 except CompilerExit:374 pass
1275 unmodified lines
modified:tests/test_regression.py+4 added
477 unmodified lines
478 '<url><loc>/</loc></url>',479 '<url><loc>/bar</loc></url>',480 '</urlset>',481 ]482483 def test_empty_if(self, env):484 t = env.from_string('{% if foo %}{% else %}42{% endif %}')485 assert t.render(foo=False) == '42'
modified:CHANGES+3 added
7 unmodified lines
8- Solved some warnings for string literals. (#646)9- Increment the bytecode cache version which was not done due to an10 oversight before.11- Corrected bad code generation and scoping for filtered loops. (#649)12- Resolved an issue where top-level output silencing after known extend13 blocks could generate invalid code when blocks where contained in if14 statements. (#651)1516Version 2.9.317-------------18(bugfix release, released on January 8th 2017)
466 unmodified lines