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.
This commit is contained in:
Victor Stinner 2022-11-10 23:58:07 +01:00 committed by GitHub
parent 1960eb005e
commit 3a1dde8f29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 66 additions and 128 deletions

View file

@ -70,8 +70,7 @@ module_init_dict(PyModuleObject *mod, PyObject *md_dict,
if (PyDict_SetItem(md_dict, &_Py_ID(__spec__), Py_None) != 0)
return -1;
if (PyUnicode_CheckExact(name)) {
Py_INCREF(name);
Py_XSETREF(mod->md_name, name);
Py_XSETREF(mod->md_name, Py_NewRef(name));
}
return 0;
@ -506,8 +505,7 @@ PyModule_GetNameObject(PyObject *m)
}
return NULL;
}
Py_INCREF(name);
return name;
return Py_NewRef(name);
}
const char *
@ -541,8 +539,7 @@ PyModule_GetFilenameObject(PyObject *m)
}
return NULL;
}
Py_INCREF(fileobj);
return fileobj;
return Py_NewRef(fileobj);
}
const char *