[Checkins] SVN: z3c.pt/branches/chrism-gen-unicode-fix/ - A bug was
fixed whereby including numeric entity elements
Chris McDonough
chrism at plope.com
Sun Jul 20 20:49:44 EDT 2008
Log message for revision 88644:
- A bug was fixed whereby including numeric entity elements
in the source of a PageTemplate would cause a UnicodeDecodeError.
[chrism]
Repeat by attempting to run the following script under an unfixed
version:
import z3c.pt
from zope.configuration import xmlconfig
xmlconfig.file('configure.zcml', z3c.pt)
pt = """<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal">
©
</html>"""
from z3c.pt.pagetemplate import PageTemplate
t = PageTemplate(pt)
t.render()
Changed:
U z3c.pt/branches/chrism-gen-unicode-fix/CHANGES.txt
U z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/generation.py
A z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/tests/test_generation.py
-=-
Modified: z3c.pt/branches/chrism-gen-unicode-fix/CHANGES.txt
===================================================================
--- z3c.pt/branches/chrism-gen-unicode-fix/CHANGES.txt 2008-07-21 00:44:01 UTC (rev 88643)
+++ z3c.pt/branches/chrism-gen-unicode-fix/CHANGES.txt 2008-07-21 00:49:43 UTC (rev 88644)
@@ -4,6 +4,10 @@
Version 0.8.x
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- A bug was fixed whereby including numeric entity elements
+ in the source of a PageTemplate would cause a UnicodeDecodeError.
+ [chrism]
+
- When templates are instantiated outside of a class-definition, a
relative file path will be made absolute using the module path.
[malthe]
Modified: z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/generation.py
===================================================================
--- z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/generation.py 2008-07-21 00:44:01 UTC (rev 88643)
+++ z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/generation.py 2008-07-21 00:49:43 UTC (rev 88644)
@@ -100,7 +100,7 @@
if args:
args += ', '
- code = self.stream.getvalue()
+ code = self.stream.getvalue().encode('utf-8')
return wrapper % (args, code), {'generation': z3c.pt.generation}
class BufferIO(list):
Added: z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/tests/test_generation.py
===================================================================
--- z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/tests/test_generation.py (rev 0)
+++ z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/tests/test_generation.py 2008-07-21 00:49:43 UTC (rev 88644)
@@ -0,0 +1,14 @@
+import unittest
+
+class TestGenerator(unittest.TestCase):
+ def test_generator_returns_utf_8_encoded_text(self):
+ from z3c.pt.generation import Generator
+ gen = Generator([])
+ from StringIO import StringIO
+ gen.stream = StringIO(u'<div>\xc2\xa9</div>')
+ code, ns = gen()
+ self.failUnless(isinstance(code, str), repr(code))
+
+def test_suite():
+ import sys
+ return unittest.findTestCases(sys.modules[__name__])
Property changes on: z3c.pt/branches/chrism-gen-unicode-fix/src/z3c/pt/tests/test_generation.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list