diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-30 23:05:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-30 23:05:40 (GMT) |
commit | 9e5bd6c54473961336aeb5bfa1568870861f9053 (patch) | |
tree | 28c8c205fa021b13ca221419fc7ba3bb76459701 | |
parent | 2a1e926d63c6d7f26493b48e5512fd147422b778 (diff) | |
download | cpython-9e5bd6c54473961336aeb5bfa1568870861f9053.zip cpython-9e5bd6c54473961336aeb5bfa1568870861f9053.tar.gz cpython-9e5bd6c54473961336aeb5bfa1568870861f9053.tar.bz2 |
pyexat uses the new Unicode API
-rw-r--r-- | Modules/pyexpat.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index bcd58d2..6a8fe6d 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1234,11 +1234,13 @@ get_pybool(int istrue) static PyObject * xmlparse_getattro(xmlparseobject *self, PyObject *nameobj) { - const Py_UNICODE *name; + Py_UCS4 first_char; int handlernum = -1; if (!PyUnicode_Check(nameobj)) goto generic; + if (PyUnicode_READY(nameobj)) + return NULL; handlernum = handlername2int(nameobj); @@ -1250,8 +1252,8 @@ xmlparse_getattro(xmlparseobject *self, PyObject *nameobj) return result; } - name = PyUnicode_AS_UNICODE(nameobj); - if (name[0] == 'E') { + first_char = PyUnicode_READ_CHAR(nameobj, 0); + if (first_char == 'E') { if (PyUnicode_CompareWithASCIIString(nameobj, "ErrorCode") == 0) return PyLong_FromLong((long) XML_GetErrorCode(self->itself)); @@ -1265,7 +1267,7 @@ xmlparse_getattro(xmlparseobject *self, PyObject *nameobj) return PyLong_FromLong((long) XML_GetErrorByteIndex(self->itself)); } - if (name[0] == 'C') { + if (first_char == 'C') { if (PyUnicode_CompareWithASCIIString(nameobj, "CurrentLineNumber") == 0) return PyLong_FromLong((long) XML_GetCurrentLineNumber(self->itself)); @@ -1276,7 +1278,7 @@ xmlparse_getattro(xmlparseobject *self, PyObject *nameobj) return PyLong_FromLong((long) XML_GetCurrentByteIndex(self->itself)); } - if (name[0] == 'b') { + if (first_char == 'b') { if (PyUnicode_CompareWithASCIIString(nameobj, "buffer_size") == 0) return PyLong_FromLong((long) self->buffer_size); if (PyUnicode_CompareWithASCIIString(nameobj, "buffer_text") == 0) |