-
-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Description
Here is an example
from mako.template import Template
text = """
<%
mydict = { 'foo': 1 }
def getkeys(x):
return { k[0]: 0 for k in x.keys() }
%>
${ ','.join( getkeys(mydict) ) }
"""
tmpl = Template(text=text, strict_undefined=True)
out = tmpl.render()
print(out)
This produces the following error:
Traceback (most recent call last):
File "/home/sgr/Programmation/mako/test3.py", line 16, in <module>
tmpl = Template(text=text, strict_undefined=True)
File "/home/sgr/Programmation/mako/mako/template.py", line 299, in __init__
(code, module) = _compile_text(self, text, filename)
File "/home/sgr/Programmation/mako/mako/template.py", line 676, in _compile_text
source, lexer = _compile(
File "/home/sgr/Programmation/mako/mako/template.py", line 656, in _compile
node = lexer.parse()
File "/home/sgr/Programmation/mako/mako/lexer.py", line 248, in parse
if self.match_python_block():
File "/home/sgr/Programmation/mako/mako/lexer.py", line 404, in match_python_block
self.append_node(
File "/home/sgr/Programmation/mako/mako/lexer.py", line 129, in append_node
node = nodecls(*args, **kwargs)
File "/home/sgr/Programmation/mako/mako/parsetree.py", line 158, in __init__
self.code = ast.PythonCode(text, **self.exception_kwargs)
File "/home/sgr/Programmation/mako/mako/ast.py", line 47, in __init__
f.visit(expr)
File "/home/sgr/Programmation/mako/mako/_ast_util.py", line 136, in visit
return self.generic_visit(node)
File "/home/sgr/Programmation/mako/mako/_ast_util.py", line 144, in generic_visit
self.visit(item)
File "/home/sgr/Programmation/mako/mako/_ast_util.py", line 135, in visit
return f(node)
File "/home/sgr/Programmation/mako/mako/pyparser.py", line 91, in visit_FunctionDef
self._visit_function(node, False)
File "/home/sgr/Programmation/mako/mako/pyparser.py", line 138, in _visit_function
self.visit(n)
File "/home/sgr/Programmation/mako/mako/_ast_util.py", line 136, in visit
return self.generic_visit(node)
File "/home/sgr/Programmation/mako/mako/_ast_util.py", line 146, in generic_visit
self.visit(value)
File "/home/sgr/Programmation/mako/mako/_ast_util.py", line 135, in visit
return f(node)
File "/home/sgr/Programmation/mako/mako/pyparser.py", line 107, in visit_DictComp
self.visit(node.elt)
AttributeError: 'DictComp' object has no attribute 'elt'
I am running Python 3.10.12 and Mako 1.3.3. It was working with Mako 1.3.2.
Metadata
Metadata
Assignees
Labels
No labels