Issue #20440: Massive replacing unsafe attribute setting code with special

macro Py_SETREF.
This commit is contained in:
Serhiy Storchaka 2015-12-24 10:39:57 +02:00
commit f006940351
28 changed files with 92 additions and 120 deletions

View file

@ -1828,8 +1828,7 @@ unicode_resize(PyObject **p_unicode, Py_ssize_t length)
_Py_INCREF_UNICODE_EMPTY();
if (!unicode_empty)
return -1;
Py_DECREF(*p_unicode);
*p_unicode = unicode_empty;
Py_SETREF(*p_unicode, unicode_empty);
return 0;
}
@ -1837,8 +1836,7 @@ unicode_resize(PyObject **p_unicode, Py_ssize_t length)
PyObject *copy = resize_copy(unicode, length);
if (copy == NULL)
return -1;
Py_DECREF(*p_unicode);
*p_unicode = copy;
Py_SETREF(*p_unicode, copy);
return 0;
}
@ -13543,8 +13541,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
return -1;
_PyUnicode_FastCopyCharacters(newbuffer, 0,
writer->buffer, 0, writer->pos);
Py_DECREF(writer->buffer);
writer->buffer = newbuffer;
Py_SETREF(writer->buffer, newbuffer);
}
_PyUnicodeWriter_Update(writer);
return 0;
@ -15261,8 +15258,7 @@ PyUnicode_InternInPlace(PyObject **p)
if (t) {
Py_INCREF(t);
Py_DECREF(*p);
*p = t;
Py_SETREF(*p, t);
return;
}