Issues

Issue #190 resolved

Using lambda as default argument breaks

guest
created an issue

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.

Comments (2)

  1. Log in to comment