summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorXiang Zhang <angwerzx@126.com>2016-11-23 11:34:01 (GMT)
committerXiang Zhang <angwerzx@126.com>2016-11-23 11:34:01 (GMT)
commitd04d8474dfde5ed584a51a43d3d177376a98fb58 (patch)
tree2ba05d5d6cfb7bf7ebbba6b41010730ef8ed5351 /Objects
parent726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef (diff)
downloadcpython-d04d8474dfde5ed584a51a43d3d177376a98fb58.zip
cpython-d04d8474dfde5ed584a51a43d3d177376a98fb58.tar.gz
cpython-d04d8474dfde5ed584a51a43d3d177376a98fb58.tar.bz2
Issue #28774: Fix start/end pos in unicode_encode_ucs1().
Fix error position of the unicode error in ASCII and Latin1 encoders when a string returned by the error handler contains multiple non-encodable characters (non-ASCII for the ASCII codec, characters out of the U+0000-U+00FF range for Latin1).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index e88a126..2bf48b7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6798,7 +6798,7 @@ unicode_encode_ucs1(PyObject *unicode,
goto onError;
/* subtract preallocated bytes */
- writer.min_size -= 1;
+ writer.min_size -= newpos - collstart;
if (PyBytes_Check(rep)) {
/* Directly copy bytes result to output. */
@@ -6835,7 +6835,7 @@ unicode_encode_ucs1(PyObject *unicode,
ch = PyUnicode_READ_CHAR(rep, i);
if (ch >= limit) {
raise_encode_exception(&exc, encoding, unicode,
- pos, pos+1, reason);
+ collstart, collend, reason);
goto onError;
}
*str = (char)ch;