mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-99300: Use Py_NewRef() in Modules/ directory (#99467)
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:
parent
3817607b8a
commit
7e4dec02ac
10 changed files with 75 additions and 144 deletions
|
|
@ -128,8 +128,7 @@ normalizeUserObj(PyObject *obj)
|
|||
{
|
||||
PyCFunctionObject *fn;
|
||||
if (!PyCFunction_Check(obj)) {
|
||||
Py_INCREF(obj);
|
||||
return obj;
|
||||
return Py_NewRef(obj);
|
||||
}
|
||||
/* Replace built-in function objects with a descriptive string
|
||||
because of built-in methods -- keeping a reference to
|
||||
|
|
@ -142,8 +141,7 @@ normalizeUserObj(PyObject *obj)
|
|||
PyObject *modname = NULL;
|
||||
if (mod != NULL) {
|
||||
if (PyUnicode_Check(mod)) {
|
||||
modname = mod;
|
||||
Py_INCREF(modname);
|
||||
modname = Py_NewRef(mod);
|
||||
}
|
||||
else if (PyModule_Check(mod)) {
|
||||
modname = PyModule_GetNameObject(mod);
|
||||
|
|
@ -555,8 +553,7 @@ static int statsForEntry(rotating_node_t *node, void *arg)
|
|||
}
|
||||
}
|
||||
else {
|
||||
Py_INCREF(Py_None);
|
||||
collect->sublist = Py_None;
|
||||
collect->sublist = Py_NewRef(Py_None);
|
||||
}
|
||||
|
||||
info = PyObject_CallFunction((PyObject*) collect->state->stats_entry_type,
|
||||
|
|
@ -781,8 +778,7 @@ profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw)
|
|||
if (setSubcalls(pObj, subcalls) < 0 || setBuiltins(pObj, builtins) < 0)
|
||||
return -1;
|
||||
pObj->externalTimerUnit = timeunit;
|
||||
Py_XINCREF(timer);
|
||||
Py_XSETREF(pObj->externalTimer, timer);
|
||||
Py_XSETREF(pObj->externalTimer, Py_XNewRef(timer));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue