[Checkins] SVN: z3c.pt/trunk/ - Fixed a few more UnicodeDecodeErrors (test contributed by Wiggy).
Chris McDonough
chrism at plope.com
Tue Aug 19 01:09:14 EDT 2008
Log message for revision 89990:
- Fixed a few more UnicodeDecodeErrors (test contributed by Wiggy).
In particular, utf-8 encode Unicode attribute keys and values in
Assign expressions (e.g. py:attrs).
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/clauses.py
U z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-08-19 04:56:24 UTC (rev 89989)
+++ z3c.pt/trunk/CHANGES.txt 2008-08-19 05:09:14 UTC (rev 89990)
@@ -4,6 +4,11 @@
Version 1.0dev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- Fixed a few more UnicodeDecodeErrors (test contributed by Wiggy).
+ In particular, never upcast to unicode during transformation, and
+ utf-8 encode Unicode attribute keys and values in Assign expressions
+ (e.g. py:attrs). [chrism]
+
- Implemented TAL global defines. [malthe]
- Added support for variables with global scope. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/clauses.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/clauses.py 2008-08-19 04:56:24 UTC (rev 89989)
+++ z3c.pt/trunk/src/z3c/pt/clauses.py 2008-08-19 05:09:14 UTC (rev 89990)
@@ -526,8 +526,14 @@
stream.write("for %s, %s in _exp.items():" % (temp, temp2))
stream.indent()
if unicode_required_flag:
- stream.write("if isinstance(%s, unicode):" % temp2)
+ stream.write(
+ "if isinstance(%s, unicode) or isinstance(%s, unicode):" % (temp, temp2))
stream.indent()
+ for t in (temp, temp2):
+ stream.write("if isinstance(%s, unicode):" % t)
+ stream.indent()
+ stream.write("%s = %s.encode('utf-8')" % (t, t))
+ stream.outdent()
stream.escape(temp2)
stream.write("_write(' %%s=\"%%s\"' %% (%s, %s))" % (temp, temp2))
stream.outdent()
Modified: z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py 2008-08-19 04:56:24 UTC (rev 89989)
+++ z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py 2008-08-19 05:09:14 UTC (rev 89990)
@@ -29,7 +29,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
foo \xc2\xa9
- </html>""".decode('utf-8')
+ </html>"""
t = PageTemplate(body)
self.assertEqual(norm(t.render(foo=u'foo')), norm(expected))
@@ -73,7 +73,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org">
- <title>\xc2\xa9n</title>
+ <title>\xc2\xa9</title>
<div id="${foo}" py:attrs="dict(label=foo)"/>
</html>
"""
@@ -82,7 +82,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title>\xc2\xa9</title>
- <div id="\xc2\xa9" label="\xc2\xa9"/>
+ <div label="\xc2\xa9" id="\xc2\xa9"/>
</html>"""
t = PageTemplate(body, parser=GenshiParser())
c = unicode('\xc2\xa9', 'utf-8')
More information about the Checkins
mailing list