summaryrefslogtreecommitdiffstats
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-10 22:58:07 (GMT)
committerGitHub <noreply@github.com>2022-11-10 22:58:07 (GMT)
commit3a1dde8f29215418ec4e27fd6234cfa19a5407c6 (patch)
tree433d4efb6105ded7a5abcc0f96360731840b10aa /Objects/methodobject.c
parent1960eb005e04b7ad8a91018088cfdb0646bc1ca0 (diff)
downloadcpython-3a1dde8f29215418ec4e27fd6234cfa19a5407c6.zip
cpython-3a1dde8f29215418ec4e27fd6234cfa19a5407c6.tar.gz
cpython-3a1dde8f29215418ec4e27fd6234cfa19a5407c6.tar.bz2
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.
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 953cf46..51752de 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -88,8 +88,7 @@ PyCMethod_New(PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *c
if (om == NULL) {
return NULL;
}
- Py_INCREF(cls);
- om->mm_class = cls;
+ om->mm_class = (PyTypeObject*)Py_NewRef(cls);
op = (PyCFunctionObject *)om;
} else {
if (cls) {
@@ -106,10 +105,8 @@ PyCMethod_New(PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *c
op->m_weakreflist = NULL;
op->m_ml = ml;
- Py_XINCREF(self);
- op->m_self = self;
- Py_XINCREF(module);
- op->m_module = module;
+ op->m_self = Py_XNewRef(self);
+ op->m_module = Py_XNewRef(module);
op->vectorcall = vectorcall;
_PyObject_GC_TRACK(op);
return (PyObject *)op;
@@ -260,8 +257,7 @@ meth_get__self__(PyCFunctionObject *m, void *closure)
self = PyCFunction_GET_SELF(m);
if (self == NULL)
self = Py_None;
- Py_INCREF(self);
- return self;
+ return Py_NewRef(self);
}
static PyGetSetDef meth_getsets [] = {
@@ -314,8 +310,7 @@ meth_richcompare(PyObject *self, PyObject *other, int op)
res = eq ? Py_True : Py_False;
else
res = eq ? Py_False : Py_True;
- Py_INCREF(res);
- return res;
+ return Py_NewRef(res);
}
static Py_hash_t