mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #20440: Cleaning up the code by using Py_SETREF and Py_CLEAR.
Old code is correct, but with Py_SETREF and Py_CLEAR it can be cleaner. This patch doesn't fix bugs and hence there is no need to backport it.
This commit is contained in:
parent
726fc139a5
commit
1ed017ae92
9 changed files with 23 additions and 71 deletions
|
@ -149,7 +149,6 @@ PyTuple_GetItem(PyObject *op, Py_ssize_t i)
|
|||
int
|
||||
PyTuple_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem)
|
||||
{
|
||||
PyObject *olditem;
|
||||
PyObject **p;
|
||||
if (!PyTuple_Check(op) || op->ob_refcnt != 1) {
|
||||
Py_XDECREF(newitem);
|
||||
|
@ -163,9 +162,7 @@ PyTuple_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem)
|
|||
return -1;
|
||||
}
|
||||
p = ((PyTupleObject *)op) -> ob_item + i;
|
||||
olditem = *p;
|
||||
*p = newitem;
|
||||
Py_XDECREF(olditem);
|
||||
Py_SETREF(*p, newitem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue