summaryrefslogtreecommitdiffstats
path: root/Objects/complexobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-10 15:27:32 (GMT)
committerGitHub <noreply@github.com>2022-11-10 15:27:32 (GMT)
commitc0feb99187f449f844621b378273776d70a50f57 (patch)
tree23251e00cd73fab30b9ae2df063ce8bc6edef3e9 /Objects/complexobject.c
parent4ce2a202c7b573edaa0ee4a2315d5578f66737c5 (diff)
downloadcpython-c0feb99187f449f844621b378273776d70a50f57.zip
cpython-c0feb99187f449f844621b378273776d70a50f57.tar.gz
cpython-c0feb99187f449f844621b378273776d70a50f57.tar.bz2
gh-99300: Use Py_NewRef() in Objects/ directory (#99332)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r--Objects/complexobject.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 9bd68d5..aee03dd 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -449,8 +449,7 @@ to_complex(PyObject **pobj, Py_complex *pc)
pc->real = PyFloat_AsDouble(obj);
return 0;
}
- Py_INCREF(Py_NotImplemented);
- *pobj = Py_NotImplemented;
+ *pobj = Py_NewRef(Py_NotImplemented);
return -1;
}
@@ -553,8 +552,7 @@ static PyObject *
complex_pos(PyComplexObject *v)
{
if (PyComplex_CheckExact(v)) {
- Py_INCREF(v);
- return (PyObject *)v;
+ return Py_NewRef(v);
}
else
return PyComplex_FromCComplex(v->cval);
@@ -631,8 +629,7 @@ complex_richcompare(PyObject *v, PyObject *w, int op)
else
res = Py_False;
- Py_INCREF(res);
- return res;
+ return Py_NewRef(res);
Unimplemented:
Py_RETURN_NOTIMPLEMENTED;
@@ -705,8 +702,7 @@ complex___complex___impl(PyComplexObject *self)
/*[clinic end generated code: output=e6b35ba3d275dc9c input=3589ada9d27db854]*/
{
if (PyComplex_CheckExact(self)) {
- Py_INCREF(self);
- return (PyObject *)self;
+ return Py_NewRef(self);
}
else {
return PyComplex_FromCComplex(self->cval);
@@ -917,8 +913,7 @@ complex_new_impl(PyTypeObject *type, PyObject *r, PyObject *i)
to exact complexes here. If either the input or the
output is a complex subclass, it will be handled below
as a non-orthogonal vector. */
- Py_INCREF(r);
- return r;
+ return Py_NewRef(r);
}
if (PyUnicode_Check(r)) {
if (i != NULL) {