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:
Serhiy Storchaka 2015-12-27 15:51:32 +02:00
parent 726fc139a5
commit 1ed017ae92
9 changed files with 23 additions and 71 deletions

View file

@ -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;
}