summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-11-20 21:50:23 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-11-20 21:50:23 (GMT)
commitda1ddf37c68f76041ca8ebb75e0016e96cc3f67b (patch)
tree9a6b64340bfd919884a3fe0df03cd438f57ced0e /Objects
parent4ead7c7be8089de7cab5db7d2a75e6bec5b55f10 (diff)
downloadcpython-da1ddf37c68f76041ca8ebb75e0016e96cc3f67b.zip
cpython-da1ddf37c68f76041ca8ebb75e0016e96cc3f67b.tar.gz
cpython-da1ddf37c68f76041ca8ebb75e0016e96cc3f67b.tar.bz2
UnicodeEncodeError uses the new Unicode API
The index is a character index, not a index in a Py_UNICODE* string.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 5b5447a..c8f90b8 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -1542,8 +1542,8 @@ UnicodeEncodeError_str(PyObject *self)
if (encoding_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 = "'%U' codec can't encode character '\\x%02x' in position %zd: %U";
@@ -1554,7 +1554,7 @@ UnicodeEncodeError_str(PyObject *self)
result = PyUnicode_FromFormat(
fmt,
encoding_str,
- badchar,
+ (int)badchar,
uself->start,
reason_str);
}