[Python-checkins] cpython: _PyUnicodeWriter_WriteStr() now checks that the input string is consistent

victor.stinner python-checkins at python.org
Thu Mar 26 09:37:33 CET 2015


https://hg.python.org/cpython/rev/a417d89fbc38
changeset: 95211:a417d89fbc38
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Mar 26 09:37:23 2015 +0100
summary:
 _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.
files:
 Objects/unicodeobject.c | 1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13422,6 +13422,7 @@
 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;
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /