[Python-checkins] cpython: Issue #28774: Fix start/end pos in unicode_encode_ucs1().
xiang.zhang
python-checkins at python.org
Wed Nov 23 07:19:24 EST 2016
https://hg.python.org/cpython/rev/3d660ed2a60e
changeset: 105344:3d660ed2a60e
user: Xiang Zhang <angwerzx at 126.com>
date: Wed Nov 23 19:34:01 2016 +0800
summary:
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).
files:
Misc/NEWS | 5 +++++
Objects/unicodeobject.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,11 @@
Core and Builtins
-----------------
+- Issue #28774: 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).
+
- Issue #28731: Optimize _PyDict_NewPresized() to create correct size dict.
Improve speed of dict literal with constant keys up to 30%.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6798,7 +6798,7 @@
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 @@
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;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list