[Python-checkins] cpython (merge 3.2 -> default): Issue #14829: Fix bisect and range() indexing with large indices (>= 2 ** 32)

antoine.pitrou python-checkins at python.org
Wed May 16 14:42:01 CEST 2012


http://hg.python.org/cpython/rev/a3784c8f165e
changeset:   76991:a3784c8f165e
parent:      76989:6e5c517da087
parent:      76990:888f5f3bfcb6
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed May 16 14:39:36 2012 +0200
summary:
  Issue #14829: Fix bisect and range() indexing with large indices (>= 2 ** 32) under 64-bit Windows.

(untested, because of Windows build issues under 3.x)

files:
  Misc/NEWS               |  3 +++
  Modules/_bisectmodule.c |  4 ++--
  Objects/rangeobject.c   |  2 +-
  3 files changed, 6 insertions(+), 3 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -34,6 +34,9 @@
 Library
 -------
 
+- Issue #14829: Fix bisect and range() indexing with large indices
+  (>= 2 ** 32) under 64-bit Windows.
+
 - Issue #14732: The _csv module now uses PEP 3121 module initialization.
   Patch by Robin Schreiber.
 
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c
--- a/Modules/_bisectmodule.c
+++ b/Modules/_bisectmodule.c
@@ -3,6 +3,7 @@
 Converted to C by Dmitry Vasiliev (dima at hlabs.spb.ru).
 */
 
+#define PY_SSIZE_T_CLEAN
 #include "Python.h"
 
 static Py_ssize_t
@@ -195,8 +196,7 @@
             return NULL;
     } else {
         _Py_IDENTIFIER(insert);
-
-        result = _PyObject_CallMethodId(list, &PyId_insert, "iO", index, item);
+        result = _PyObject_CallMethodId(list, &PyId_insert, "nO", index, item);
         if (result == NULL)
             return NULL;
         Py_DECREF(result);
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -308,7 +308,7 @@
 static PyObject *
 range_item(rangeobject *r, Py_ssize_t i)
 {
-    PyObject *res, *arg = PyLong_FromLong(i);
+    PyObject *res, *arg = PyLong_FromSsize_t(i);
     if (!arg) {
         return NULL;
     }

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


More information about the Python-checkins mailing list