Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Unhelpful error message with unquoted HTML attributes #98

Open
xiaq opened this Issue · 1 comment

2 participants

@xiaq

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/template.py", 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/template.py", line 120, in __init__
    self.write(body)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/template.py", line 207, in write
    self.cook(body)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/template.py", 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/template.py", line 217, in _cook
    source = self._make(body, builtins)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/template.py", line 248, in _make
    program = self.parse(body)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/zpt/template.py", line 202, in parse
    trim_attribute_space=self.trim_attribute_space,
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/zpt/program.py", 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/program.py", line 31, in __init__
    for kind, args in parser:
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/parser.py", line 182, in __iter__
    item = self.parse(token)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/parser.py", line 190, in parse
    return visitor(kind, token)
  File "/usr/lib/python2.7/site-packages/Chameleon-2.7.3-py2.7.egg/chameleon/parser.py", 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.

@malthe
Owner

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.