From 7e4dec02ac86bcbe958f299f68ed25d543c23ef9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 14 Nov 2022 13:08:43 +0100 Subject: 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. --- Modules/_lsprof.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'Modules/_lsprof.c') 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; } -- cgit v1.2.1