diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-24 08:39:57 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-24 08:39:57 (GMT) |
commit | f0069403518243e37da0aaaa1148d9dfee1adebd (patch) | |
tree | c6fc0eb9f3dc2b917e2f998cb25e59248453d49d /Objects/unicodeobject.c | |
parent | 2bd58e39918d83c639366c69a4da247238f8183f (diff) | |
parent | 5a57ade58ec5bee85db41b8ce1340ff077781b65 (diff) | |
download | cpython-f0069403518243e37da0aaaa1148d9dfee1adebd.zip cpython-f0069403518243e37da0aaaa1148d9dfee1adebd.tar.gz cpython-f0069403518243e37da0aaaa1148d9dfee1adebd.tar.bz2 |
Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index ad8f505..a985d6f 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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; } |