diff options
| author | Victor Stinner <vstinner@python.org> | 2022-11-10 23:58:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-10 23:58:07 +0100 |
| commit | 3a1dde8f29215418ec4e27fd6234cfa19a5407c6 (patch) | |
| tree | 433d4efb6105ded7a5abcc0f96360731840b10aa /Objects/stringlib | |
| parent | 1960eb005e04b7ad8a91018088cfdb0646bc1ca0 (diff) | |
| download | cpython-git-3a1dde8f29215418ec4e27fd6234cfa19a5407c6.tar.gz | |
gh-99300: Use Py_NewRef() in Objects/ directory (#99354)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Objects/ directory.
Diffstat (limited to 'Objects/stringlib')
| -rw-r--r-- | Objects/stringlib/join.h | 3 | ||||
| -rw-r--r-- | Objects/stringlib/transmogrify.h | 3 | ||||
| -rw-r--r-- | Objects/stringlib/unicode_format.h | 9 |
3 files changed, 5 insertions, 10 deletions
diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h index bb011f7db7..de6bd83ffe 100644 --- a/Objects/stringlib/join.h +++ b/Objects/stringlib/join.h @@ -63,8 +63,7 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) item = PySequence_Fast_GET_ITEM(seq, i); if (PyBytes_CheckExact(item)) { /* Fast path. */ - Py_INCREF(item); - buffers[i].obj = item; + buffers[i].obj = Py_NewRef(item); buffers[i].buf = PyBytes_AS_STRING(item); buffers[i].len = PyBytes_GET_SIZE(item); } diff --git a/Objects/stringlib/transmogrify.h b/Objects/stringlib/transmogrify.h index e1165ea38e..71099bb586 100644 --- a/Objects/stringlib/transmogrify.h +++ b/Objects/stringlib/transmogrify.h @@ -17,8 +17,7 @@ return_self(PyObject *self) { #if !STRINGLIB_MUTABLE if (STRINGLIB_CHECK_EXACT(self)) { - Py_INCREF(self); - return self; + return Py_NewRef(self); } #endif return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self)); diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h index a4eea7b919..e970588a7e 100644 --- a/Objects/stringlib/unicode_format.h +++ b/Objects/stringlib/unicode_format.h @@ -1042,8 +1042,7 @@ formatteriter_next(formatteriterobject *it) otherwise create a one length string with the conversion character */ if (conversion == '\0') { - conversion_str = Py_None; - Py_INCREF(conversion_str); + conversion_str = Py_NewRef(Py_None); } else conversion_str = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, @@ -1121,8 +1120,7 @@ formatter_parser(PyObject *ignored, PyObject *self) return NULL; /* take ownership, give the object to the iterator */ - Py_INCREF(self); - it->str = self; + it->str = Py_NewRef(self); /* initialize the contained MarkupIterator */ MarkupIterator_init(&it->it_markup, (PyObject*)self, 0, PyUnicode_GET_LENGTH(self)); @@ -1265,8 +1263,7 @@ formatter_field_name_split(PyObject *ignored, PyObject *self) /* take ownership, give the object to the iterator. this is just to keep the field_name alive */ - Py_INCREF(self); - it->str = self; + it->str = Py_NewRef(self); /* Pass in auto_number = NULL. We'll return an empty string for first_obj in that case. */ |
