[Python-checkins] cpython: Issue #25414: Remove unnecessary tests that can never succeed.

raymond.hettinger python-checkins at python.org
Sat Oct 17 02:47:34 EDT 2015


https://hg.python.org/cpython/rev/1733b3bd46db
changeset:   98774:1733b3bd46db
user:        Raymond Hettinger <python at rcn.com>
date:        Fri Oct 16 22:47:29 2015 -0700
summary:
  Issue #25414: Remove unnecessary tests that can never succeed.

files:
  Modules/_collectionsmodule.c |  16 +---------------
  1 files changed, 1 insertions(+), 15 deletions(-)


diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -110,12 +110,6 @@
 #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 *
 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 @@
         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 @@
         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();
     }
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list