Fix the unexpected error that occurs when an empty control block is used.#387
Fix the unexpected error that occurs when an empty control block is used.#387cocolato wants to merge 2 commits into
Conversation
|
cool. can we add changelog files to these patches? Dont worry about getting them perfect I can fix them up later example 1d6c58e#diff-22252f506a8da7ab5343802f53f7c35770390f669fe0f73a9e2345f0914ebb98 |
sqla-tester
left a comment
There was a problem hiding this comment.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision d0a0981 of this pull request into gerrit so we can run tests and reviews and stuff
|
New Gerrit review created for change d0a0981: https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5148 |
|
Ok, it has been updated. |
sqla-tester
left a comment
There was a problem hiding this comment.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 571a73a of this pull request into gerrit so we can run tests and reviews and stuff
|
Patchset 571a73a added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5148 |
zzzeek
left a comment
There was a problem hiding this comment.
some changes. also inside the commit block, if you can modify this on push (use git commit --amend) , add the fixes line:
Fixes: #146
Closes: #387
Pull-request: https://github.com/sqlalchemy/mako/pull/387
Pull-request-sha: 571a73a1d84ee922b38ce5817a5822fbe0268cd0
| return True | ||
| return False | ||
|
|
||
| if should_add_pass(node, children): |
There was a problem hiding this comment.
my comment didnt get transmitted from gerrit.
can we change this, so that we are using the same conditional from the old version, and just this last part with the "for c in children" is moved into a function def _search_for_control_line(). that way the form of the conditional stays the same and we move just that one check.
like this:
if not children or (
all(
isinstance(c, (parsetree.Comment, parsetree.ControlLine))
for c in children
)
and all(
(node.is_ternary(c.keyword) or c.isend)
for c in children
if isinstance(c, parsetree.ControlLine)
)
) or _search_for_control_line(children):
self.printer.writeline("pass")571a73a to
6ae0c91
Compare
6ae0c91 to
f816f1f
Compare
Closes: sqlalchemy#387 Pull-request: sqlalchemy#387 Pull-request-sha: f816f1f
|
Thanks so much for your help! Everything's been updated now. |
sqla-tester
left a comment
There was a problem hiding this comment.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision fb257ff of this pull request into gerrit so we can run tests and reviews and stuff
|
Patchset fb257ff added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5148 |
sqla-tester
left a comment
There was a problem hiding this comment.
Michael Bayer (zzzeek) wrote:
code review left on gerrit
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5148
- /COMMIT_MSG (line 34): Done
- mako/codegen.py (line 862): Done
|
Michael Bayer (zzzeek) wrote: graet, thanks View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5148 |
|
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5148 has been merged. Congratulations! :) |
…sed. Fixes: sqlalchemy/mako#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: sqlalchemy/mako#387 Pull-request-sha: fb257ff866148a79bfe58ccaf7c98f499f8d8424 Change-Id: Ief78cdf4eb39b6e8257332ed034dab052c715420
Fixes: #146
When the first control block is empty or comment, the correct result will now be rendered.
Result: