[Python-checkins] cpython (merge default -> default): Merge heads

serhiy.storchaka python-checkins at python.org
Sun Mar 1 09:04:28 CET 2015


https://hg.python.org/cpython/rev/1aafce84a865
changeset:   94797:1aafce84a865
parent:      94796:d6dff5a5290a
parent:      94793:570d78391343
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sun Mar 01 10:03:46 2015 +0200
summary:
  Merge heads

files:
  Modules/_collectionsmodule.c |  18 ++++++++++++------
  1 files changed, 12 insertions(+), 6 deletions(-)


diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1,6 +1,12 @@
 #include "Python.h"
 #include "structmember.h"
 
+#ifdef STDC_HEADERS
+#include <stddef.h>
+#else
+#include <sys/types.h>          /* For size_t */
+#endif
+
 /* collections module implementation of a deque() datatype
    Written and maintained by Raymond D. Hettinger <python at rcn.com>
    Copyright (c) 2004-2015 Python Software Foundation.
@@ -780,15 +786,15 @@
         b = deque->rightblock;
     } else {
         i += deque->leftindex;
-        n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
-        i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
+        n = (Py_ssize_t)((size_t) i / BLOCKLEN);
+        i = (Py_ssize_t)((size_t) i % BLOCKLEN);
         if (index < (Py_SIZE(deque) >> 1)) {
             b = deque->leftblock;
             while (n--)
                 b = b->rightlink;
         } else {
             n = (Py_ssize_t)(
-                    ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
+                    ((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
                     / BLOCKLEN - n);
             b = deque->rightblock;
             while (n--)
@@ -839,15 +845,15 @@
         return deque_del_item(deque, i);
 
     i += deque->leftindex;
-    n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
-    i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
+    n = (Py_ssize_t)((size_t) i / BLOCKLEN);
+    i = (Py_ssize_t)((size_t) i % BLOCKLEN);
     if (index <= halflen) {
         b = deque->leftblock;
         while (n--)
             b = b->rightlink;
     } else {
         n = (Py_ssize_t)(
-                ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
+                ((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
                 / BLOCKLEN - n);
         b = deque->rightblock;
         while (n--)

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


More information about the Python-checkins mailing list