mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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:
parent
1acdfec359
commit
20d9749a0f
2 changed files with 28 additions and 57 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue