mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
_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.
This commit is contained in:
parent
aa4c36fbbb
commit
1912b39def
1 changed files with 1 additions and 0 deletions
|
@ -13422,6 +13422,7 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str)
|
||||||
maxchar = PyUnicode_MAX_CHAR_VALUE(str);
|
maxchar = PyUnicode_MAX_CHAR_VALUE(str);
|
||||||
if (maxchar > writer->maxchar || len > writer->size - writer->pos) {
|
if (maxchar > writer->maxchar || len > writer->size - writer->pos) {
|
||||||
if (writer->buffer == NULL && !writer->overallocate) {
|
if (writer->buffer == NULL && !writer->overallocate) {
|
||||||
|
assert(_PyUnicode_CheckConsistency(str, 1));
|
||||||
writer->readonly = 1;
|
writer->readonly = 1;
|
||||||
Py_INCREF(str);
|
Py_INCREF(str);
|
||||||
writer->buffer = str;
|
writer->buffer = str;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue