diff -r e392f1b88fff Modules/_elementtree.c --- a/Modules/_elementtree.c Mon May 20 10:28:48 2013 -0700 +++ b/Modules/_elementtree.c Tue May 21 06:21:52 2013 +0300 @@ -3117,6 +3117,8 @@ if (PyUnicode_GET_LENGTH(u) != 256) { Py_DECREF(u); + PyErr_SetString(PyExc_ValueError, + "multi-byte encodings are not supported"); return XML_STATUS_ERROR; } diff -r e392f1b88fff Modules/pyexpat.c --- a/Modules/pyexpat.c Mon May 20 10:28:48 2013 -0700 +++ b/Modules/pyexpat.c Tue May 21 06:21:52 2013 +0300 @@ -1129,7 +1129,6 @@ XML_Encoding *info) { PyUnicodeObject *_u_string = NULL; - int result = 0; int i; int kind; void *data; @@ -1139,7 +1138,14 @@ PyUnicode_Decode(template_buffer, 256, name, "replace"); if (_u_string == NULL || PyUnicode_READY(_u_string) == -1) - return result; + return XML_STATUS_ERROR; + + if (PyUnicode_GET_LENGTH(_u_string) != 256) { + Py_DECREF(_u_string); + PyErr_SetString(PyExc_ValueError, + "multi-byte encodings are not supported"); + return XML_STATUS_ERROR; + } kind = PyUnicode_KIND(_u_string); data = PyUnicode_DATA(_u_string); @@ -1155,9 +1161,8 @@ info->data = NULL; info->convert = NULL; info->release = NULL; - result = 1; Py_DECREF(_u_string); - return result; + return XML_STATUS_OK; }