mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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.
This commit is contained in:
parent
4ce2a202c7
commit
c0feb99187
9 changed files with 77 additions and 156 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue