diff options
author | Raymond Hettinger <python@rcn.com> | 2005-03-19 00:00:51 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-03-19 00:00:51 (GMT) |
commit | d73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f (patch) | |
tree | 0bfe624c8356dec97a46644233eae277b641dbbe /Modules/collectionsmodule.c | |
parent | 4aec61e0fc29217c93acd0615ad54bd081a64658 (diff) | |
download | cpython-d73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f.zip cpython-d73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f.tar.gz cpython-d73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f.tar.bz2 |
Apply remove's mutation test after every equality test.
Diffstat (limited to 'Modules/collectionsmodule.c')
-rw-r--r-- | Modules/collectionsmodule.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/collectionsmodule.c b/Modules/collectionsmodule.c index 49c486f..2fbd729 100644 --- a/Modules/collectionsmodule.c +++ b/Modules/collectionsmodule.c @@ -376,14 +376,14 @@ deque_remove(dequeobject *deque, PyObject *value) for (i=0 ; i<n ; i++) { PyObject *item = deque->leftblock->data[deque->leftindex]; int cmp = PyObject_RichCompareBool(item, value, Py_EQ); + + if (deque->len != n) { + PyErr_SetString(PyExc_IndexError, + "deque mutated during remove()."); + return NULL; + } if (cmp > 0) { - PyObject *tgt; - if (deque->len != n) { - PyErr_SetString(PyExc_IndexError, - "deque mutated during remove()."); - return NULL; - } - tgt = deque_popleft(deque, NULL); + PyObject *tgt = deque_popleft(deque, NULL); assert (tgt != NULL); Py_DECREF(tgt); if (_deque_rotate(deque, i) == -1) |