summaryrefslogtreecommitdiff
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-14 13:08:43 +0100
committerGitHub <noreply@github.com>2022-11-14 13:08:43 +0100
commit7e4dec02ac86bcbe958f299f68ed25d543c23ef9 (patch)
treebc9999d57707f92f6dc390fed16af10f71e29ddb /Modules/_lsprof.c
parent3817607b8a345851e4fa436747a346890ced33f1 (diff)
downloadcpython-git-7e4dec02ac86bcbe958f299f68ed25d543c23ef9.tar.gz
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.
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r--Modules/_lsprof.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index a0e262bdac..cb80c8d339 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -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;
}