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).
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%.
goto onError;
/* subtract preallocated bytes */
- writer.min_size -= 1;
+ writer.min_size -= newpos - collstart;
if (PyBytes_Check(rep)) {
/* Directly copy bytes result to output. */
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;