summaryrefslogtreecommitdiffstats
path: root/Objects/unionobject.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/unionobject.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/unionobject.c')
-rw-r--r--Objects/unionobject.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/Objects/unionobject.c b/Objects/unionobject.c
index 5eee27c..b2ac350 100644
--- a/Objects/unionobject.c
+++ b/Objects/unionobject.c
@@ -114,12 +114,10 @@ merge(PyObject **items1, Py_ssize_t size1,
}
for (; pos < size1; pos++) {
PyObject *a = items1[pos];
- Py_INCREF(a);
- PyTuple_SET_ITEM(tuple, pos, a);
+ PyTuple_SET_ITEM(tuple, pos, Py_NewRef(a));
}
}
- Py_INCREF(arg);
- PyTuple_SET_ITEM(tuple, pos, arg);
+ PyTuple_SET_ITEM(tuple, pos, Py_NewRef(arg));
pos++;
}
@@ -170,8 +168,7 @@ _Py_union_type_or(PyObject* self, PyObject* other)
if (PyErr_Occurred()) {
return NULL;
}
- Py_INCREF(self);
- return self;
+ return Py_NewRef(self);
}
PyObject *new_union = make_union(tuple);
@@ -326,8 +323,7 @@ union_parameters(PyObject *self, void *Py_UNUSED(unused))
return NULL;
}
}
- Py_INCREF(alias->parameters);
- return alias->parameters;
+ return Py_NewRef(alias->parameters);
}
static PyGetSetDef union_properties[] = {
@@ -400,9 +396,8 @@ make_union(PyObject *args)
return NULL;
}
- Py_INCREF(args);
result->parameters = NULL;
- result->args = args;
+ result->args = Py_NewRef(args);
_PyObject_GC_TRACK(result);
return (PyObject*)result;
}