summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2011-09-28 05:41:54 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2011-09-28 05:41:54 (GMT)
commitd63a3b8beb4a0841cb59fb3515347ccaab34b733 (patch)
tree3b4e3cc63151c5a5a910c3550a190aefaea96ad4 /Modules/pyexpat.c
parent48d49497c50e79d14e9df9527d766ca3a0a38be5 (diff)
downloadcpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.zip
cpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.tar.gz
cpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.tar.bz2
Implement PEP 393.
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index d923eeb..bcd58d2 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1102,17 +1102,22 @@ PyUnknownEncodingHandler(void *encodingHandlerData,
PyUnicodeObject *_u_string = NULL;
int result = 0;
int i;
+ int kind;
+ void *data;
/* Yes, supports only 8bit encodings */
_u_string = (PyUnicodeObject *)
PyUnicode_Decode(template_buffer, 256, name, "replace");
- if (_u_string == NULL)
+ if (_u_string == NULL || PyUnicode_READY(_u_string) == -1)
return result;
+ kind = PyUnicode_KIND(_u_string);
+ data = PyUnicode_DATA(_u_string);
+
for (i = 0; i < 256; i++) {
/* Stupid to access directly, but fast */
- Py_UNICODE c = _u_string->str[i];
+ Py_UCS4 c = PyUnicode_READ(kind, data, i);
if (c == Py_UNICODE_REPLACEMENT_CHARACTER)
info->map[i] = -1;
else
@@ -1229,7 +1234,7 @@ get_pybool(int istrue)
static PyObject *
xmlparse_getattro(xmlparseobject *self, PyObject *nameobj)
{
- Py_UNICODE *name;
+ const Py_UNICODE *name;
int handlernum = -1;
if (!PyUnicode_Check(nameobj))