-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty block in middle of %if...%elif...%elif...%else...%endif doesn't get a pass in the Python, leading to an IndentationError #146
Comments
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. |
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. |
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:
|
Changes by Michael Bayer (@zzzeek):
|
Hi there, it seems that if the empty statement is the first one it still fails: from mako.template import Template
template = r"""
% if True:
% elif lose:
test
% elif False:
broken
% endif
"""
t = Template(template)
print(t.render()) # IndentationError: expected an indented block So the bug is not entirely fixed. |
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. |
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! |
Sure! github lets you do all that stuff too. |
Closes: sqlalchemy#387 Pull-request: sqlalchemy#387 Pull-request-sha: f816f1f
…sed. Fixes: #146 When the first control block is empty or comment, the correct result will now be rendered. ```python from mako.template import Template template = r""" % if False: % elif False: % else: test % endif """ t = Template(template) print(t.render()) ``` Result: ``` test ``` Closes: #387 Pull-request: #387 Pull-request-sha: fb257ff Change-Id: Ief78cdf4eb39b6e8257332ed034dab052c715420
Migrated issue, originally created by Anonymous
How-To-Reproduce:
Results:
An IndentationError pointing at the next line of code after the do-nothing block, complaining that Python was expecting an indented block.
Workaround:
Add <%pass%> to the do-nothing block
Attachments: 146.patch | 146.2.patch | 146.3.patch
The text was updated successfully, but these errors were encountered: