diff -r ee0bdc007a0f Lib/test/test_xml_etree.py
--- a/Lib/test/test_xml_etree.py Sat Aug 03 20:24:00 2013 +0200
+++ b/Lib/test/test_xml_etree.py Sun Aug 04 13:19:51 2013 +0300
@@ -883,6 +883,12 @@
>>> check_encoding("iso-8859-15")
>>> check_encoding("cp437")
>>> check_encoding("mac-roman")
+>>> check_encoding("gbk")
+ Traceback (most recent call last):
+ ValueError: multi-byte encodings are not supported
+>>> check_encoding("cp037")
+ Traceback (most recent call last):
+ ParseError: unknown encoding: line 1, column 30
"""
ET.XML("" % encoding)
diff -r ee0bdc007a0f Modules/_elementtree.c
--- a/Modules/_elementtree.c Sat Aug 03 20:24:00 2013 +0200
+++ b/Modules/_elementtree.c Sun Aug 04 13:19:51 2013 +0300
@@ -2427,6 +2427,8 @@
if (PyUnicode_GET_SIZE(u) != 256) {
Py_DECREF(u);
+ PyErr_SetString(PyExc_ValueError,
+ "multi-byte encodings are not supported");
return XML_STATUS_ERROR;
}
diff -r ee0bdc007a0f Modules/pyexpat.c
--- a/Modules/pyexpat.c Sat Aug 03 20:24:00 2013 +0200
+++ b/Modules/pyexpat.c Sun Aug 04 13:19:51 2013 +0300
@@ -1252,6 +1252,13 @@
if (_u_string == NULL)
return result;
+ if (PyUnicode_GET_SIZE(_u_string) != 256) {
+ Py_DECREF(_u_string);
+ PyErr_SetString(PyExc_ValueError,
+ "multi-byte encodings are not supported");
+ return result;
+ }
+
for (i = 0; i < 256; i++) { /* Stupid to access directly, but fast */ Py_UNICODE c = _u_string->str[i];