summaryrefslogtreecommitdiffstats
path: root/Modules/xxmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-14 15:21:40 (GMT)
committerGitHub <noreply@github.com>2022-11-14 15:21:40 (GMT)
commit65dd745f1a343dd80f5e612736f36200631f2840 (patch)
tree2a81bd2f9067811f2b0386a5a60081072fbbfb7e /Modules/xxmodule.c
parent3e2f7135e6164860b763cf5d0d22b9dc12409767 (diff)
downloadcpython-65dd745f1a343dd80f5e612736f36200631f2840.zip
cpython-65dd745f1a343dd80f5e612736f36200631f2840.tar.gz
cpython-65dd745f1a343dd80f5e612736f36200631f2840.tar.bz2
gh-99300: Use Py_NewRef() in Modules/ directory (#99473)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
Diffstat (limited to 'Modules/xxmodule.c')
-rw-r--r--Modules/xxmodule.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index a6e5071..a676fdb 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -52,8 +52,7 @@ Xxo_demo(XxoObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, ":demo"))
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ return Py_NewRef(Py_None);
}
static PyMethodDef Xxo_methods[] = {
@@ -68,8 +67,7 @@ Xxo_getattro(XxoObject *self, PyObject *name)
if (self->x_attr != NULL) {
PyObject *v = PyDict_GetItemWithError(self->x_attr, name);
if (v != NULL) {
- Py_INCREF(v);
- return v;
+ return Py_NewRef(v);
}
else if (PyErr_Occurred()) {
return NULL;
@@ -195,8 +193,7 @@ xx_bug(PyObject *self, PyObject *args)
printf("\n");
/* Py_DECREF(item); */
- Py_INCREF(Py_None);
- return Py_None;
+ return Py_NewRef(Py_None);
}
/* Test bad format character */
@@ -208,8 +205,7 @@ xx_roj(PyObject *self, PyObject *args)
long b;
if (!PyArg_ParseTuple(args, "O#:roj", &a, &b))
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ return Py_NewRef(Py_None);
}
@@ -266,8 +262,7 @@ static PyTypeObject Str_Type = {
static PyObject *
null_richcompare(PyObject *self, PyObject *other, int op)
{
- Py_INCREF(Py_NotImplemented);
- return Py_NotImplemented;
+ return Py_NewRef(Py_NotImplemented);
}
static PyTypeObject Null_Type = {