diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-21 00:17:27 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-21 00:17:27 (GMT) |
commit | 53b33e767d9aa85f2bf3add5850499596f9d0558 (patch) | |
tree | 3a6dc041509e03ee5bacbfc17af85f6c33392ca2 /Objects/exceptions.c | |
parent | a1c03b0a587ec971360c4f57a801631bba2dd5f1 (diff) | |
download | cpython-53b33e767d9aa85f2bf3add5850499596f9d0558.zip cpython-53b33e767d9aa85f2bf3add5850499596f9d0558.tar.gz cpython-53b33e767d9aa85f2bf3add5850499596f9d0558.tar.bz2 |
UnicodeTranslateError uses the new Unicode API
The index is a character index, not a index in a Py_UNICODE* string.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index c8f90b8..a1b79a8 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -1751,8 +1751,8 @@ UnicodeTranslateError_str(PyObject *self) if (reason_str == NULL) goto done; - if (uself->start < PyUnicode_GET_SIZE(uself->object) && uself->end == uself->start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start]; + if (uself->start < PyUnicode_GET_LENGTH(uself->object) && uself->end == uself->start+1) { + Py_UCS4 badchar = PyUnicode_ReadChar(uself->object, uself->start); const char *fmt; if (badchar <= 0xff) fmt = "can't translate character '\\x%02x' in position %zd: %U"; @@ -1762,7 +1762,7 @@ UnicodeTranslateError_str(PyObject *self) fmt = "can't translate character '\\U%08x' in position %zd: %U"; result = PyUnicode_FromFormat( fmt, - badchar, + (int)badchar, uself->start, reason_str ); |