gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)

Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef()
and Py_XNewRef().
This commit is contained in:
Victor Stinner 2022-11-16 18:34:24 +01:00 committed by GitHub
parent 19c1462e8d
commit 8211cf5d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 40 additions and 74 deletions

View file

@ -1459,8 +1459,7 @@ merge_consts_recursive(PyObject *const_cache, PyObject *o)
}
PyObject *u;
if (PyTuple_CheckExact(k)) {
u = PyTuple_GET_ITEM(k, 1);
Py_INCREF(u);
u = Py_NewRef(PyTuple_GET_ITEM(k, 1));
Py_DECREF(k);
}
else {
@ -2732,8 +2731,7 @@ compiler_class(struct compiler *c, stmt_ty s)
{
location loc = LOCATION(firstlineno, firstlineno, 0, 0);
/* use the class name for name mangling */
Py_INCREF(s->v.ClassDef.name);
Py_XSETREF(c->u->u_private, s->v.ClassDef.name);
Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name));
/* load (global) __name__ ... */
if (!compiler_nameop(c, loc, &_Py_ID(__name__), Load)) {
compiler_exit_scope(c);