[2.7] bpo-33677: Fix the signature of tp_clear handler for deque. (GH-7196). (GH-7277)
(cherry picked from commit a5c42284e69fb309bdd17ee8c1c120d1be383012)
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 2e4da4c..9364aba 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -639,7 +639,7 @@
PyDoc_STRVAR(remove_doc,
"D.remove(value) -- remove first occurrence of value.");
-static void
+static int
deque_clear(dequeobject *deque)
{
block *b;
@@ -650,7 +650,7 @@
PyObject *item;
if (deque->len == 0)
- return;
+ return 0;
/* During the process of clearing a deque, decrefs can cause the
deque to mutate. To avoid fatal confusion, we have to make the
@@ -701,7 +701,7 @@
}
assert(leftblock->rightlink == NULL);
freeblock(leftblock);
- return;
+ return 0;
alternate_method:
while (deque->len) {
@@ -709,6 +709,7 @@
assert (item != NULL);
Py_DECREF(item);
}
+ return 0;
}
static PyObject *