Use unsigned division and modulo for item assignment as well.
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index d12f0e8..908cfd2 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -780,7 +780,6 @@
b = deque->rightblock;
} else {
i += deque->leftindex;
- assert(i >= 0);
n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
if (index < (Py_SIZE(deque) >> 1)) {
@@ -840,14 +839,16 @@
return deque_del_item(deque, i);
i += deque->leftindex;
- n = i / BLOCKLEN;
- i %= BLOCKLEN;
+ n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
+ i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
if (index <= halflen) {
b = deque->leftblock;
while (n--)
b = b->rightlink;
} else {
- n = (deque->leftindex + len - 1) / BLOCKLEN - n;
+ n = (Py_ssize_t)(
+ ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
+ / BLOCKLEN - n);
b = deque->rightblock;
while (n--)
b = b->leftlink;