gh-99300: Use Py_NewRef() in Modules/ directory (#99469)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the Modules/ directory.
This commit is contained in:
Victor Stinner 2022-11-14 16:21:23 +01:00 • committed by GitHub
parent e3d4fed074
commit 3e2f7135e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 66 additions and 130 deletions

View file

@ -2048,8 +2048,7 @@ factorial_odd_part(unsigned long n)
inner = PyLong_FromLong(1);
if (inner == NULL)
return NULL;
outer = inner;
Py_INCREF(outer);
outer = Py_NewRef(inner);
upper = 3;
for (i = _Py_bit_length(n) - 2; i >= 0; i--) {
@ -3521,8 +3520,7 @@ perm_comb(PyObject *n, unsigned long long k, int iscomb)
return PyLong_FromLong(1);
}
if (k == 1) {
Py_INCREF(n);
return n;
return Py_NewRef(n);
}
/* P(n, k) = P(n, j) * P(n-j, k-j) */