Although this error is relatively easy to work-around (stop using python builtins or reserved names as variable names in tal:define), it's hard to understand what happens by the error message.
Here is a simple reproduction. Replace the code in src/chameleon/tests/templates/helloworld.pt with:
Traceback (most recent call last):
File "/home/leo/Workspace/shome-212-20110125/rebootstrap.1.parts/python2.6/lib/python2.6/doctest.py", line 1253, in __run compileflags, 1) in test.globs
File "<doctest template.txt[7]>", line 1, in <module>
print t()
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/core/template.py", line 104, in __call__
return self.render(**kwargs)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/core/template.py", line 402, in render
return super(TemplateFile, self).render(*args, **kwargs)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/zpt/template.py", line 17, in render
return super(PageTemplate, self).render(*args, **kwargs)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/core/template.py", line 229, in render
return self.cook_and_render(kwargs, utils.emptydict, None, True)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/core/template.py", line 382, in cook_and_render
args, slots, macro, global_scope)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/core/template.py", line 189, in cook_and_render
source = self.compiler(macro, global_scope)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/core/translation.py", line 1065, in __call__
suite = codegen.Suite(source)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/core/codegen.py", line 213, in __init__
node = parse(source, self.mode)
File "/home/leo/Workspace/2.12-perf/src/Chameleon/src/chameleon/ast/astutil.py", line 22, in parse
return compile(source, '', mode, _ast.PyCF_ONLY_AST)
File "<string>", line 22
class = 'class'
^
SyntaxError: invalid syntax
Although this error is relatively easy to work-around (stop using python builtins or reserved names as variable names in tal:define), it's hard to understand what happens by the error message.
Here is a simple reproduction. Replace the code in src/chameleon/ tests/templates /helloworld. pt with:
<div xmlns="http:// www.w3. org/1999/ xhtml" tal:define="class 'class'">
Hello World!
</div>
And the following error is raised:
Traceback (most recent call last): leo/Workspace/ shome-212- 20110125/ rebootstrap. 1.parts/ python2. 6/lib/python2. 6/doctest. py", line 1253, in __run
compileflags, 1) in test.globs leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ core/template. py", line 104, in __call__ **kwargs) leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ core/template. py", line 402, in render leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ zpt/template. py", line 17, in render leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ core/template. py", line 229, in render and_render( kwargs, utils.emptydict, None, True) leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ core/template. py", line 382, in cook_and_render leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ core/template. py", line 189, in cook_and_render macro, global_scope) leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ core/translatio n.py", line 1065, in __call__ Suite(source) leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ core/codegen. py", line 213, in __init__ leo/Workspace/ 2.12-perf/ src/Chameleon/ src/chameleon/ ast/astutil. py", line 22, in parse
File "/home/
File "<doctest template.txt[7]>", line 1, in <module>
print t()
File "/home/
return self.render(
File "/home/
return super(TemplateFile, self).render(*args, **kwargs)
File "/home/
return super(PageTemplate, self).render(*args, **kwargs)
File "/home/
return self.cook_
File "/home/
args, slots, macro, global_scope)
File "/home/
source = self.compiler(
File "/home/
suite = codegen.
File "/home/
node = parse(source, self.mode)
File "/home/
return compile(source, '', mode, _ast.PyCF_ONLY_AST)
File "<string>", line 22
class = 'class'
^
SyntaxError: invalid syntax