Fix empty statement block #546

wants to merge 2 commits into


None yet

2 participants


The following code will throw exception, because the generated code didn't add "pass" for empty "if" statement. The same for other ControlBlocks.

template = Template(utf8("{% if x > 4 %}{%elif x < 0%}{%else%}{%end%}"))

I am not sure if this is the cleanest fix though, it should be the simplest one.

tornadoweb member

There's no harm in emitting a "pass" statement when it's not needed (I verified with the disassembler), so I'm going to commit a simpler version that doesn't check whether the block is empty.

@bdarnell bdarnell added a commit that closed this pull request Aug 27, 2012
@bdarnell bdarnell Fix template errors with empty blocks.
Emits a "pass" statement in every generated block whether it's empty or not;
I verified with the disassembler that the unnecessary pass statements
don't generate extra bytecodes.

Closes #546.
@bdarnell bdarnell closed this in 54d91d5 Aug 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment