[Zope3-checkins] SVN: Zope3/trunk/src/zope/tal/t A small fix (with a test) for a trailing semicolon on i18n:attributes, which would generate a very cryptic compilation error resulting from an indexerror raised inside talgenerator when compiling the page template.

Sidnei da Silva sidnei at awkly.org
Tue Jun 22 17:03:48 EDT 2004


Log message for revision 25947:
A small fix (with a test) for a trailing semicolon on i18n:attributes, which would generate a very cryptic compilation error resulting from an indexerror raised inside talgenerator when compiling the page template.


-=-
Modified: Zope3/trunk/src/zope/tal/talgenerator.py
===================================================================
--- Zope3/trunk/src/zope/tal/talgenerator.py	2004-06-22 21:01:51 UTC (rev 25946)
+++ Zope3/trunk/src/zope/tal/talgenerator.py	2004-06-22 21:03:48 UTC (rev 25947)
@@ -840,7 +840,11 @@
 
 def _parseI18nAttributes(i18nattrs, position, xml):
     d = {}
-    for spec in i18nattrs.split(";"):
+    # Filter out empty items, eg:
+    # i18n:attributes="value msgid; name msgid2;"
+    # would result in 3 items where the last one is empty
+    attrs = filter(None, i18nattrs.split(";"))
+    for spec in attrs:
         parts = spec.split()
         if len(parts) > 2:
             raise TALError("illegal i18n:attributes specification: %r" % spec,

Modified: Zope3/trunk/src/zope/tal/tests/input/test24.html
===================================================================
--- Zope3/trunk/src/zope/tal/tests/input/test24.html	2004-06-22 21:01:51 UTC (rev 25946)
+++ Zope3/trunk/src/zope/tal/tests/input/test24.html	2004-06-22 21:03:48 UTC (rev 25947)
@@ -7,3 +7,6 @@
 
 <input i18n:attributes=" name message-id;
                          attr input-attr ">
+
+<input i18n:attributes=" name message-id;
+                         attr input-attr;">

Modified: Zope3/trunk/src/zope/tal/tests/output/test24.html
===================================================================
--- Zope3/trunk/src/zope/tal/tests/output/test24.html	2004-06-22 21:01:51 UTC (rev 25946)
+++ Zope3/trunk/src/zope/tal/tests/output/test24.html	2004-06-22 21:03:48 UTC (rev 25947)
@@ -3,3 +3,5 @@
 <input name="MESSAGE-ID">
 
 <input name="MESSAGE-ID" attr="INPUT-ATTR">
+
+<input name="MESSAGE-ID" attr="INPUT-ATTR">




More information about the Zope3-Checkins mailing list