summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-03-19 00:00:51 (GMT)
committerRaymond Hettinger <python@rcn.com>2005-03-19 00:00:51 (GMT)
commitd73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f (patch)
tree0bfe624c8356dec97a46644233eae277b641dbbe /Modules
parent4aec61e0fc29217c93acd0615ad54bd081a64658 (diff)
downloadcpython-d73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f.zip
cpython-d73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f.tar.gz
cpython-d73202c596e730d8bfb22edb1a6c4cc2f0e9ca6f.tar.bz2
Apply remove's mutation test after every equality test.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/collectionsmodule.c14
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)