[New-bugs-announce] [issue20945] why save the item to be replaced as olditem in PyTuple_SetItem? It's not useful at all.

coder.maliubiao report at bugs.python.org
Sun Mar 16 16:08:05 CET 2014


New submission from coder.maliubiao:

code:
int
PyTuple_SetItem(register PyObject *op, register Py_ssize_t i, PyObject *newitem)
{
    register PyObject *olditem;
    register PyObject **p;
    if (!PyTuple_Check(op) || op->ob_refcnt != 1) {
        Py_XDECREF(newitem);
        PyErr_BadInternalCall();
        return -1;
    }
    if (i < 0 || i >= Py_SIZE(op)) {
        Py_XDECREF(newitem);
        PyErr_SetString(PyExc_IndexError,
                        "tuple assignment index out of range");
        return -1;
    }
    p = ((PyTupleObject *)op) -> ob_item + i;
    olditem = *p;
    *p = newitem;
    Py_XDECREF(olditem);
    return 0;
}

olditem is not useful.

----------
components: Devguide
messages: 213730
nosy: ezio.melotti, maliubiao at gmail.com
priority: normal
severity: normal
status: open
title: why save the item to be replaced as olditem in PyTuple_SetItem?  It's not useful at all.
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20945>
_______________________________________


More information about the New-bugs-announce mailing list