gh-99300: Use Py_NewRef() in Modules/ directory (#99466)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the Modules/ directory.
This commit is contained in:
Victor Stinner 2022-11-14 13:08:15 +01:00 committed by GitHub
parent db115682bd
commit 3817607b8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 106 additions and 214 deletions

View file

@ -176,8 +176,7 @@ get_char_or_None(Py_UCS4 c)
static PyObject *
Dialect_get_lineterminator(DialectObj *self, void *Py_UNUSED(ignored))
{
Py_XINCREF(self->lineterminator);
return self->lineterminator;
return Py_XNewRef(self->lineterminator);
}
static PyObject *
@ -316,8 +315,7 @@ _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt)
else {
if (PyUnicode_READY(src) == -1)
return -1;
Py_INCREF(src);
Py_XSETREF(*target, src);
Py_XSETREF(*target, Py_NewRef(src));
}
}
return 0;
@ -514,8 +512,7 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
goto err;
}
ret = (PyObject *)self;
Py_INCREF(self);
ret = Py_NewRef(self);
err:
Py_CLEAR(self);
Py_CLEAR(dialect);