[pypy-svn] r79638 - in pypy/trunk/pypy/module/pyexpat: . test

fijal at codespeak.net fijal at codespeak.net
Mon Nov 29 14:14:39 CET 2010


Author: fijal
Date: Mon Nov 29 14:14:37 2010
New Revision: 79638

Modified:
   pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py
   pypy/trunk/pypy/module/pyexpat/test/test_parser.py
Log:
(hodgestar) fix to pyexpat module
issue578 resolved.


Modified: pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py
==============================================================================
--- pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py	(original)
+++ pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py	Mon Nov 29 14:14:37 2010
@@ -329,7 +329,7 @@
         if self.returns_unicode:
             return space.call_function(
                 space.getattr(space.wrap(s), space.wrap("decode")),
-                space.wrap(self.encoding),
+                space.wrap("utf-8"),
                 space.wrap("strict"))
         else:
             return space.wrap(s)

Modified: pypy/trunk/pypy/module/pyexpat/test/test_parser.py
==============================================================================
--- pypy/trunk/pypy/module/pyexpat/test/test_parser.py	(original)
+++ pypy/trunk/pypy/module/pyexpat/test/test_parser.py	Mon Nov 29 14:14:37 2010
@@ -15,3 +15,17 @@
         assert res == 1
 
         raises(pyexpat.ExpatError, p.Parse, "3")
+
+    def test_encoding(self):
+        import pyexpat
+        for encoding_arg in (None, 'utf-8', 'iso-8859-1'):
+            for namespace_arg in (None, '{'):
+                print encoding_arg, namespace_arg
+                p = pyexpat.ParserCreate(encoding_arg, namespace_arg)
+                data = []
+                p.CharacterDataHandler = lambda s: data.append(s)
+                encoding = encoding_arg is None and 'utf-8' or encoding_arg
+
+                res = p.Parse(u"<xml>\u00f6</xml>".encode(encoding), isfinal=True)
+                assert res == 1
+                assert data == [u"\u00f6"]



More information about the Pypy-commit mailing list