From 20151f50f6942f32584ece6e751e1edb59699007 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 16 Oct 2015 22:47:29 -0700 Subject: [PATCH] Issue #25414: Remove unnecessary tests that can never succeed. --- Modules/_collectionsmodule.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 1acbf86bf44..ceba0376ed1 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -110,12 +110,6 @@ static PyTypeObject deque_type; #define CHECK_NOT_END(link) #endif -/* To prevent len from overflowing PY_SSIZE_T_MAX, we refuse to - allocate new blocks if the current len is nearing overflow. -*/ - -#define MAX_DEQUE_LEN (PY_SSIZE_T_MAX - 3*BLOCKLEN) - /* A simple freelisting scheme is used to minimize calls to the memory allocator. It accommodates common use cases where new blocks are being added at about the same rate as old blocks are being freed. @@ -128,11 +122,6 @@ static block *freeblocks[MAXFREEBLOCKS]; static block * newblock(Py_ssize_t len) { block *b; - if (len >= MAX_DEQUE_LEN) { - PyErr_SetString(PyExc_OverflowError, - "cannot add more blocks to the deque"); - return NULL; - } if (numfreeblocks) { numfreeblocks--; return freeblocks[numfreeblocks]; @@ -676,9 +665,6 @@ deque_inplace_repeat(dequeobject *deque, Py_ssize_t n) if (deque->maxlen >= 0 && n > deque->maxlen) n = deque->maxlen; - if (n > MAX_DEQUE_LEN) - return PyErr_NoMemory(); - deque->state++; for (i = 0 ; i < n-1 ; ) { if (deque->rightindex == BLOCKLEN - 1) { @@ -709,7 +695,7 @@ deque_inplace_repeat(dequeobject *deque, Py_ssize_t n) return (PyObject *)deque; } - if ((size_t)size > MAX_DEQUE_LEN / (size_t)n) { + if ((size_t)size > PY_SSIZE_T_MAX / (size_t)n) { return PyErr_NoMemory(); }