diff options
author | Raymond Hettinger <python@rcn.com> | 2016-02-02 05:19:22 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-02-02 05:19:22 (GMT) |
commit | b00da57561505eb220a107fab0e7fbc322f767ac (patch) | |
tree | d781959a29d40965a7cc0aaf4c3a5c8cc03b0411 /Modules/_collectionsmodule.c | |
parent | 3e7230904e475982d0aea2c0181ea9e04e0ac6b3 (diff) | |
download | cpython-b00da57561505eb220a107fab0e7fbc322f767ac.zip cpython-b00da57561505eb220a107fab0e7fbc322f767ac.tar.gz cpython-b00da57561505eb220a107fab0e7fbc322f767ac.tar.bz2 |
Issue #26194: Inserting into a full deque to raise an IndexError
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r-- | Modules/_collectionsmodule.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index b9c4f3b..10fbcfe 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -973,16 +973,13 @@ deque_insert(dequeobject *deque, PyObject *args) Py_ssize_t index; Py_ssize_t n = Py_SIZE(deque); PyObject *value; - PyObject *oldvalue; PyObject *rv; if (!PyArg_ParseTuple(args, "nO:insert", &index, &value)) return NULL; if (deque->maxlen == Py_SIZE(deque)) { - if (index >= deque->maxlen || Py_SIZE(deque) == 0) - Py_RETURN_NONE; - oldvalue = deque_pop(deque, NULL); - Py_DECREF(oldvalue); + PyErr_SetString(PyExc_IndexError, "deque already at its maximum size"); + return NULL; } if (index >= n) return deque_append(deque, value); |