summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-24 08:35:59 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-24 08:35:59 (GMT)
commit5a57ade58ec5bee85db41b8ce1340ff077781b65 (patch)
tree2f8cf61efba46284b2d4437916bc3469d23c0ce3 /Objects/unicodeobject.c
parenta198645fa0f9a9c6183c211955083765dc8ab3a8 (diff)
downloadcpython-5a57ade58ec5bee85db41b8ce1340ff077781b65.zip
cpython-5a57ade58ec5bee85db41b8ce1340ff077781b65.tar.gz
cpython-5a57ade58ec5bee85db41b8ce1340ff077781b65.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.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 0b78301..c5b35e1 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1665,8 +1665,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;
}
@@ -1674,8 +1673,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;
}
@@ -13322,8 +13320,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;
@@ -15009,8 +15006,7 @@ PyUnicode_InternInPlace(PyObject **p)
if (t) {
Py_INCREF(t);
- Py_DECREF(*p);
- *p = t;
+ Py_SETREF(*p, t);
return;
}