From: Raymond Hettinger Date: Sat, 17 Oct 2015 05:47:29 +0000 (-0700) Subject: Issue #25414: Remove unnecessary tests that can never succeed. X-Git-Tag: v3.6.0a1~1200 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=20151f50f6942f32584ece6e751e1edb59699007;p=thirdparty%2FPython%2Fcpython.git Issue #25414: Remove unnecessary tests that can never succeed. --- diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 1acbf86bf443..ceba0376ed14 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(); }