[Python-Dev] Re: [Python-checkins] python/dist/src/Modules
collectionsmodule.c, 1.2, 1.3
Neal Norwitz
neal at metaslash.com
Fri Feb 6 21:26:52 EST 2004
On Fri, Feb 06, 2004 at 11:04:59AM -0800, rhettinger at users.sourceforge.net wrote:
>
> + static PyObject *
> + deque_extend(dequeobject *deque, PyObject *iterable)
> + {
> + PyObject *it, *item;
> +
> + it = PyObject_GetIter(iterable);
> + if (it == NULL)
> + return NULL;
> +
> + while ((item = PyIter_Next(it)) != NULL) {
> + deque->rightindex++;
> + deque->len++;
> + if (deque->rightindex == BLOCKLEN) {
> + block *b = newblock(deque->rightblock, NULL);
> + if (b == NULL)
> + return NULL;
In deque_extend and deque_extendleft, doesn't there need
to be a Py_DECREF(it); before returning when newblock fails?
> + assert(deque->rightblock->rightlink == NULL);
> + deque->rightblock->rightlink = b;
> + deque->rightblock = b;
> + deque->rightindex = 0;
> + }
> + Py_INCREF(item);
> + deque->rightblock->data[deque->rightindex] = item;
> + }
> + Py_DECREF(it);
> + if (PyErr_Occurred())
> + return NULL;
> + Py_RETURN_NONE;
> + }
More information about the Python-Dev
mailing list