You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty block in middle of %if...%elif...%elif...%else...%endif doesn't get a pass in the Python, leading to an IndentationError #146
Don't you have to add a 'pass' in that same situation in Python? Isn't this asking mako behavior to diverge from Python unnecessarily? Although it would indeed be more convenient to not have to manually insert the pass statement.
unfortunately Mako needs a maintainer to be able to look into these issues, I can only submit PRs with tests I don't have time to diagnose intricate issues like these.
The remaining case reported here — where the first control block in the chain is empty (or contains only a comment) — was fixed in commit 7a19fbe via #387 (thanks @cocolato), released in Mako 1.3.3.
The code generator now inserts a pass for four situations, including "the first control block with no content other than comments." Regression tests (test_blank_control_9/10/11, test_commented_blank_control_9/10 in ControlTest) cover these variants.
Verified on current main that all reported variants — middle-empty, middle-empty-with-comment, first-empty, first-empty-with-comment, and all-empty — now compile and render correctly. Closing.
Activity
sqlalchemy-bot commentedon Aug 10, 2010
Michael Bayer (@zzzeek) wrote:
a very old bug which I thought we had a bug report for, thought we fixed, but all these assumptions (except the first) are wrong.
sqlalchemy-bot commentedon Jun 25, 2011
Anonymous wrote:
Don't you have to add a 'pass' in that same situation in Python? Isn't this asking mako behavior to diverge from Python unnecessarily? Although it would indeed be more convenient to not have to manually insert the pass statement.
sqlalchemy-bot commentedon Apr 3, 2012
Michael Bayer (@zzzeek) wrote:
the patch is in 1b4d1fb but doesn't actually fix the above test case, it appears that the comment line screws it up:
taking out the comment, it's fine:
sqlalchemy-bot commentedon Apr 6, 2012
Michael Bayer (@zzzeek) wrote:
great, 8cce610 and we're done ! thanks!
sqlalchemy-bot commentedon Apr 6, 2012
Changes by Michael Bayer (@zzzeek):
smarie commentedon Apr 12, 2019
Hi there, it seems that if the empty statement is the first one it still fails:
So the bug is not entirely fixed.
zzzeek commentedon Apr 12, 2019
hi there -
unfortunately Mako needs a maintainer to be able to look into these issues, I can only submit PRs with tests I don't have time to diagnose intricate issues like these.
smarie commentedon Apr 12, 2019
no worries I found a workaround, but could you please just reopen the ticket so that when a maintainer is active, he will know what to fix ? Thanks!
zzzeek commentedon Apr 12, 2019
Sure! github lets you do all that stuff too.
Fixes: sqlalchemy#146
Fix the unexpected error that occurs when an empty control block is u…
Fix the unexpected error that occurs when an empty control block is u…
zzzeek commentedon Aug 4, 2026
The remaining case reported here — where the first control block in the chain is empty (or contains only a comment) — was fixed in commit 7a19fbe via #387 (thanks @cocolato), released in Mako 1.3.3.
The code generator now inserts a
passfor four situations, including "the first control block with no content other than comments." Regression tests (test_blank_control_9/10/11,test_commented_blank_control_9/10inControlTest) cover these variants.Verified on current
mainthat all reported variants — middle-empty, middle-empty-with-comment, first-empty, first-empty-with-comment, and all-empty — now compile and render correctly. Closing.