From: Victor Stinner Date: Thu, 26 Mar 2015 08:37:23 +0000 (+0100) Subject: _PyUnicodeWriter_WriteStr() now checks that the input string is consistent X-Git-Tag: v3.5.0a3~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1912b39deffe416f6b0c16df64b634a3e55fd424;p=python _PyUnicodeWriter_WriteStr() now checks that the input string is consistent in debug mode to detect bugs earlier. _PyUnicodeWriter_Finish() doesn't check if the read only string is consistent, whereas it does check consistency for strings built by itself. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5343b2106f..e494e4a146 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13422,6 +13422,7 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str) maxchar = PyUnicode_MAX_CHAR_VALUE(str); if (maxchar > writer->maxchar || len > writer->size - writer->pos) { if (writer->buffer == NULL && !writer->overallocate) { + assert(_PyUnicode_CheckConsistency(str, 1)); writer->readonly = 1; Py_INCREF(str); writer->buffer = str;