gh-99537: Use Py_SETREF() function in longobject C code (#99655)

Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);"
in longobject.c and _testcapi/long.c.
This commit is contained in:
Victor Stinner 2022-11-22 13:04:19 +01:00 committed by GitHub
parent 1acdfec359
commit 20d9749a0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 57 deletions

View file

@ -121,8 +121,7 @@ test_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
}
temp = PyNumber_Add(num, one);
Py_DECREF(one);
Py_DECREF(num);
num = temp;
Py_SETREF(num, temp);
if (num == NULL)
return NULL;
overflow = 0;
@ -165,8 +164,7 @@ test_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
}
temp = PyNumber_Subtract(num, one);
Py_DECREF(one);
Py_DECREF(num);
num = temp;
Py_SETREF(num, temp);
if (num == NULL)
return NULL;
overflow = 0;
@ -285,8 +283,7 @@ test_long_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
}
temp = PyNumber_Add(num, one);
Py_DECREF(one);
Py_DECREF(num);
num = temp;
Py_SETREF(num, temp);
if (num == NULL)
return NULL;
overflow = 0;
@ -329,8 +326,7 @@ test_long_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
}
temp = PyNumber_Subtract(num, one);
Py_DECREF(one);
Py_DECREF(num);
num = temp;
Py_SETREF(num, temp);
if (num == NULL)
return NULL;
overflow = 0;