Comment 1 for bug 701627

Revision history for this message
LeoRochael (leorochael) wrote :

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):
      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