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

@ -47,9 +47,8 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname
PyCodeObject *code_obj = (PyCodeObject *)Py_NewRef(code);
PyObject *name = code_obj->co_name;
assert(name != NULL);
Py_INCREF(name);
assert(code_obj->co_name != NULL);
PyObject *name = Py_NewRef(code_obj->co_name);
if (!qualname) {
qualname = code_obj->co_qualname;
@ -525,10 +524,7 @@ func_get_annotations(PyFunctionObject *op, void *Py_UNUSED(ignored))
return NULL;
}
PyObject *d = func_get_annotation_dict(op);
if (d) {
Py_INCREF(d);
}
return d;
return Py_XNewRef(d);
}
static int