[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/tal/t Fix
collector issue #264: Substituting a Unicode value containing
non-ASCII
Fred L. Drake, Jr.
fdrake at gmail.com
Tue Aug 31 19:24:35 EDT 2004
Log message for revision 27373:
Fix collector issue #264: Substituting a Unicode value containing non-ASCII
text into a translated string caused a UnicodeDecodeError.
(merged from trunk revision 27372)
Changed:
U Zope3/branches/ZopeX3-3.0/src/zope/tal/talinterpreter.py
U Zope3/branches/ZopeX3-3.0/src/zope/tal/tests/test_talinterpreter.py
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/tal/talinterpreter.py 2004-08-31 23:02:38 UTC (rev 27372)
+++ Zope3/branches/ZopeX3-3.0/src/zope/tal/talinterpreter.py 2004-08-31 23:24:35 UTC (rev 27373)
@@ -498,7 +498,7 @@
value = self.engine.translate(value)
if not structure:
- value = cgi.escape(str(value))
+ value = cgi.escape(unicode(value))
# Either the i18n:name tag is nested inside an i18n:translate in which
# case the last item on the stack has the i18n dictionary and string
Modified: Zope3/branches/ZopeX3-3.0/src/zope/tal/tests/test_talinterpreter.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/tal/tests/test_talinterpreter.py 2004-08-31 23:02:38 UTC (rev 27372)
+++ Zope3/branches/ZopeX3-3.0/src/zope/tal/tests/test_talinterpreter.py 2004-08-31 23:24:35 UTC (rev 27373)
@@ -216,7 +216,15 @@
'<div>THIS IS TEXT FOR <span>BARVALUE</span>.</div>\n',
result.getvalue())
+ def test_for_handling_unicode_vars(self):
+ # Make sure that non-ASCII Unicode is substituted correctly.
+ # http://collector.zope.org/Zope3-dev/264
+ program, macros = self._compile(
+ "<div i18n:translate='' tal:define='bar python:unichr(0xC0)'>"
+ "Foo <span tal:replace='bar' i18n:name='bar' /></div>")
+ self._check(program, u"<div>FOO \u00C0</div>\n")
+
class ScriptTestCase(TestCaseBase):
def setUp(self):
More information about the Zope3-Checkins
mailing list