gh-99300: Use Py_NewRef() in Python/ directory (#99302)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Python/ directory.
This commit is contained in:
Victor Stinner 2022-11-10 09:03:39 +01:00 committed by GitHub
parent f883b7f8ee
commit d8f239d86e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 41 additions and 80 deletions

View file

@ -1046,8 +1046,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
/* Encode object */
if (!recode_strings &&
(PyBytes_Check(arg) || PyByteArray_Check(arg))) {
s = arg;
Py_INCREF(s);
s = Py_NewRef(arg);
if (PyBytes_Check(arg)) {
size = PyBytes_GET_SIZE(s);
ptr = PyBytes_AS_STRING(s);
@ -2575,8 +2574,7 @@ _PyArg_UnpackKeywordsWithVararg(PyObject *const *args, Py_ssize_t nargs,
/* copy tuple args */
for (i = 0; i < nargs; i++) {
if (i >= vararg) {
Py_INCREF(args[i]);
PyTuple_SET_ITEM(buf[vararg], i - vararg, args[i]);
PyTuple_SET_ITEM(buf[vararg], i - vararg, Py_NewRef(args[i]));
continue;
}
else {