Skip to content

Commit

Permalink
- A bug was fixed whereby including numeric entity elements
Browse files Browse the repository at this point in the history
  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">
&#169;
</html>"""
from z3c.pt.pagetemplate import PageTemplate
t = PageTemplate(pt)
t.render()
  • Loading branch information
mcdonc committed Jul 21, 2008
1 parent c798771 commit 1f4933e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
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]
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/pt/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __call__(self):
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):
Expand Down
14 changes: 14 additions & 0 deletions src/z3c/pt/tests/test_generation.py
Original file line number Diff line number Diff line change
@@ -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__])

0 comments on commit 1f4933e

Please sign in to comment.