gh-99300: Use Py_NewRef() in Objects/ directory (#99335)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Objects/ directory.
This commit is contained in:
Victor Stinner 2022-11-10 22:22:02 +01:00 committed by GitHub
parent 2f4af2d99c
commit 584e55bd34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 120 additions and 244 deletions

View file

@ -371,8 +371,7 @@ convert_to_double(PyObject **v, double *dbl)
}
}
else {
Py_INCREF(Py_NotImplemented);
*v = Py_NotImplemented;
*v = Py_NewRef(Py_NotImplemented);
return -1;
}
return 0;
@ -904,8 +903,7 @@ float_is_integer_impl(PyObject *self)
PyExc_ValueError);
return NULL;
}
Py_INCREF(o);
return o;
return Py_NewRef(o);
}
/*[clinic input]
@ -1124,11 +1122,12 @@ float___round___impl(PyObject *self, PyObject *o_ndigits)
static PyObject *
float_float(PyObject *v)
{
if (PyFloat_CheckExact(v))
Py_INCREF(v);
else
v = PyFloat_FromDouble(((PyFloatObject *)v)->ob_fval);
return v;
if (PyFloat_CheckExact(v)) {
return Py_NewRef(v);
}
else {
return PyFloat_FromDouble(((PyFloatObject *)v)->ob_fval);
}
}
/*[clinic input]