Commit dc01d2e4 authored by Evan Simpson's avatar Evan Simpson

Made tal:attribute parser more strict, and replaces "print" statements with raised exceptions.

parent 57cfe411
......@@ -12,3 +12,6 @@ TAL changes
- tal:atributes was creating stray attributes in METAL
expansion, and there was no unit test for this behavior.
- tal:attributes parsing was not catching badly malformed
values, and used "print" instead of raising exceptions.
......@@ -153,7 +153,7 @@ class TALESError(TALError):
self.info = info
import re
_attr_re = re.compile(r"\s*([^\s]+)\s*(.*)\Z", re.S)
_attr_re = re.compile(r"\s*([^\s]+)\s+([^\s].*)\Z", re.S)
_subst_re = re.compile(r"\s*(?:(text|structure)\s+)?(.*)\Z", re.S)
del re
......@@ -162,12 +162,10 @@ def parseAttributeReplacements(arg):
for part in splitParts(arg):
m = _attr_re.match(part)
if not m:
print "Bad syntax in attributes:", `part`
continue
raise TALError("Bad syntax in attributes:" + `part`)
name, expr = m.group(1, 2)
if dict.has_key(name):
print "Duplicate attribute name in attributes:", `part`
continue
raise TALError("Duplicate attribute name in attributes:" + `part`)
dict[name] = expr
return dict
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment