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

Composed def leads to infinite recursion #186

Closed
sqlalchemy-bot opened this Issue Mar 8, 2012 · 4 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Mar 8, 2012

Migrated issue, originally created by Anonymous

Okay, this time I'm almost positive this counts as a bug, as opposed to me doing something wierd.

This leads to a RuntimeError: maximum recursion depth exceeded.

from mako.template import Template

tmpl = Template("""
<%def name="f()">${caller.body()}</%def>
<%def name="g()">${caller.body()}</%def>

<%def name="fg()">
  <%self:f><%self:g>${caller.body()}</%self:g></%self:f>
</%def>

<%self:fg>body</%self:fg>
""")

print tmpl.render()

When I have a chance, I'll see if I can come up with a patch.


Attachments: ticket186.patch

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 8, 2012

Anonymous wrote:

Here's a patch. (I'm not positive this is the right fix.)
(Patch is on mako-0.6.2 and includes a test case for this problem.)

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 8, 2012

Michael Bayer (@zzzeek) wrote:

I think it's the right fix (though granted this is really brain twisting code I could barely understand even when I was writing it), as what we're looking for with _get_caller() is what we pushed on with _push_frame(). I've consolidated in 936a524 so that _push_frame() just returns the value into __M_caller - saves us a method call too ! thanks !

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 8, 2012

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 8, 2012

Anonymous wrote:

Replying to [comment:2 zzzeek]:

I think it's the right fix (though granted this is really brain twisting code I could barely understand even when I was writing it)

Good — it is two to zero for, then! (I'm glad to hear that you are human too :-)

I've consolidated in 936a524 so that _push_frame() just returns the value into __M_caller - saves us a method call too.

Looks good. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment