PyObject *repunicode = NULL;
Py_ssize_t insize;
Py_ssize_t newpos;
+ Py_ssize_t replen;
PyObject *inputobj = NULL;
if (*errorHandler == NULL) {
if (PyUnicode_READY(repunicode) < 0)
goto onError;
- if (PyUnicode_GET_LENGTH(repunicode) > 1)
+ replen = PyUnicode_GET_LENGTH(repunicode);
+ writer->min_length += replen;
+ if (replen > 1)
writer->overallocate = 1;
if (_PyUnicodeWriter_WriteStr(writer, repunicode) == -1)
goto onError;
}
_PyUnicodeWriter_Init(&writer);
- if (_PyUnicodeWriter_Prepare(&writer, size, 127) == -1)
+ writer.min_length = size;
+ if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) == -1)
goto onError;
writer.pos = ascii_decode(s, end, writer.data);
#endif
_PyUnicodeWriter_Init(&writer);
- if (_PyUnicodeWriter_Prepare(&writer, (e - q + 3) / 4, 127) == -1)
+ writer.min_length = (e - q + 3) / 4;
+ if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) == -1)
goto onError;
while (1) {
/* Note: size will always be longer than the resulting Unicode
character count */
_PyUnicodeWriter_Init(&writer);
- if (_PyUnicodeWriter_Prepare(&writer, (e - q + 1) / 2, 127) == -1)
+ writer.min_length = (e - q + 1) / 2;
+ if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) == -1)
goto onError;
while (1) {
return get_latin1_char((unsigned char)s[0]);
_PyUnicodeWriter_Init(&writer);
- if (_PyUnicodeWriter_Prepare(&writer, size, 127) < 0)
+ writer.min_length = size;
+ if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) < 0)
return NULL;
e = s + size;
if (size == 0)
_Py_RETURN_UNICODE_EMPTY();
_PyUnicodeWriter_Init(&writer);
- if (_PyUnicodeWriter_Prepare(&writer, size, 127) == -1)
+ writer.min_length = size;
+ if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) == -1)
goto onError;
e = s + size;