Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.6
Changeset: r69593:ae3ed95563a4
Date: 2014-03-01 20:44 -0500
http://bitbucket.org/pypy/pypy/changeset/ae3ed95563a4/

Log:    merge heads

diff --git a/pypy/module/pyexpat/interp_pyexpat.py 
b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -336,7 +336,7 @@
     try:
         parser.UnknownEncodingHandler(space, name, info)
     except OperationError, e:
-        if parser._exc_info:
+        if not parser._exc_info:
             parser._exc_info = e
         XML_StopParser(parser.itself, XML_FALSE)
         result = 0
@@ -584,6 +584,10 @@
                 space.wrap(self.all_chars), "decode",
                 space.wrap(name), space.wrap("replace")))
 
+        if len(translationmap) != 256:
+            raise oefmt(space.w_ValueError,
+                        "multi-byte encodings are not supported")
+
         for i in range(256):
             c = translationmap[i]
             if c == u'\ufffd':
diff --git a/pypy/module/pyexpat/test/test_parser.py 
b/pypy/module/pyexpat/test/test_parser.py
--- a/pypy/module/pyexpat/test/test_parser.py
+++ b/pypy/module/pyexpat/test/test_parser.py
@@ -2,7 +2,7 @@
 from pytest import skip
 
 class AppTestPyexpat:
-    spaceconfig = dict(usemodules=['pyexpat'])
+    spaceconfig = dict(usemodules=['pyexpat', '_multibytecodec'])
 
     def teardown_class(cls):
         global_storage.clear()
@@ -109,6 +109,13 @@
         p.CharacterDataHandler = gotText
         p.Parse(xml)
 
+    def test_mbcs(self):
+        xml = "<?xml version='1.0' encoding='gbk'?><p/>"
+        import pyexpat
+        p = pyexpat.ParserCreate()
+        exc = raises(ValueError, p.Parse, xml)
+        assert str(exc.value) == "multi-byte encodings are not supported"
+
     def test_decode_error(self):
         xml = '<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>'
         import pyexpat
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to