summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-02-02 05:19:22 (GMT)
committerRaymond Hettinger <python@rcn.com>2016-02-02 05:19:22 (GMT)
commitb00da57561505eb220a107fab0e7fbc322f767ac (patch)
treed781959a29d40965a7cc0aaf4c3a5c8cc03b0411 /Modules/_collectionsmodule.c
parent3e7230904e475982d0aea2c0181ea9e04e0ac6b3 (diff)
downloadcpython-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.c7
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);