Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Unhelpful error message with unquoted HTML attributes #98

xiaq opened this Issue · 1 comment

2 participants


Minimal case:

>>> from chameleon import PageTemplate
>>> PageTemplate('''<p id=3 tal:content="'Hi'"></p>''')()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/zpt/", line 163, in __init__
    super(PageTemplate, self).__init__(body, **config)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 120, in __init__
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 207, in write
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 150, in cook
    program = self._cook(body, digest, names)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 217, in _cook
    source = self._make(body, builtins)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 248, in _make
    program = self.parse(body)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/zpt/", line 202, in parse
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/zpt/", line 141, in __init__
    super(MacroProgram, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 31, in __init__
    for kind, args in parser:
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 182, in __iter__
    item = self.parse(token)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 190, in parse
    return visitor(kind, token)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/", line 227, in visit_end_tag
    raise ParseError("Unexpected end tag.", token)
chameleon.exc.ParseError: Unexpected end tag.

 - String:   "</p>"
 - Filename: <string>

However the following doesn't cause any trouble:

>>> PageTemplate('''<p tal:content="'Hi'" id=3></p>''')()
u'<p id=3>Hi</p>'

Seems it only happens when some unquoted HTML attribute precede a tal: attribute.


It's a strange issue because if you self-close the tag, then there's no error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.