Skip to content
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
Closed

Composed def leads to infinite recursion #186

sqlalchemy-bot opened this issue Mar 8, 2012 · 4 comments
Labels
bug Something isn't working compiler low priority

Comments

@sqlalchemy-bot
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Author

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!

@sqlalchemy-bot sqlalchemy-bot added compiler low priority bug Something isn't working labels Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler low priority
Projects
None yet
Development

No branches or pull requests

1 participant