Skip to content

Using lambda as default argument breaks #190

@sqlalchemy-bot

Description

@sqlalchemy-bot

Migrated issue, originally created by Anonymous

Running this code:

from mako.template import Template

TEXT = """\
<%def name="foo(bar=lambda x, y: x + y)">
    bar(4700, 11)
</%def>

${foo()}
"""

print(Template(TEXT).render())

...results in:

Traceback (most recent call last):
  File "tmp/mako-test/test.py", line 11, in <module>
    print(Template(TEXT).render())
  File "/usr/lib64/python3.2/site-packages/mako/template.py", line 258, in __init__
    (code, module) = _compile_text(self, text, filename)
  File "/usr/lib64/python3.2/site-packages/mako/template.py", line 606, in _compile_text
    code = compile(source, cid, 'exec')
  File "memory:0x7f5927b35ed0", line 18
    def foo(bar=lambda , : (x + y)):
                       ^
SyntaxError: invalid syntax

Expected output:

4711

Tested on version 0.7.0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions