diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-20 17:28:55 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-20 17:28:55 (GMT) |
commit | ae4f7c8e596eb224d8f24d21f8c87a10b98e07af (patch) | |
tree | 16d914ca5122031fdcf69ce8a41c6a35ec5dd029 /Objects | |
parent | 7c8bbbbb0c24350eca5e8bfb8223d3f01c90646c (diff) | |
download | cpython-ae4f7c8e596eb224d8f24d21f8c87a10b98e07af.zip cpython-ae4f7c8e596eb224d8f24d21f8c87a10b98e07af.tar.gz cpython-ae4f7c8e596eb224d8f24d21f8c87a10b98e07af.tar.bz2 |
charmap_encoding_error() uses the new Unicode API
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 90a4fcb..68e0586 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8087,7 +8087,9 @@ charmap_encoding_error( PyObject *repunicode = NULL; /* initialize to prevent gcc warning */ Py_ssize_t size, repsize; Py_ssize_t newpos; - Py_UNICODE *uni2; + enum PyUnicode_Kind kind; + void *data; + Py_ssize_t index; /* startpos for collecting unencodable chars */ Py_ssize_t collstartpos = *inpos; Py_ssize_t collendpos = *inpos+1; @@ -8201,10 +8203,18 @@ charmap_encoding_error( break; } /* generate replacement */ + if (PyUnicode_READY(repunicode) < 0) { + Py_DECREF(repunicode); + return -1; + } repsize = PyUnicode_GET_SIZE(repunicode); - for (uni2 = PyUnicode_AS_UNICODE(repunicode); repsize-->0; ++uni2) { - x = charmapencode_output(*uni2, mapping, res, respos); + data = PyUnicode_DATA(repunicode); + kind = PyUnicode_KIND(repunicode); + for (index = 0; index < repsize; index++) { + Py_UCS4 repch = PyUnicode_READ(kind, data, index); + x = charmapencode_output(repch, mapping, res, respos); if (x==enc_EXCEPTION) { + Py_DECREF(repunicode); return -1; } else if (x==enc_FAILED) { |