]> granicus.if.org Git - python/commitdiff
Issue #14829: Fix bisect and range() indexing with large indices (>= 2 ** 32) under...
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 16 May 2012 12:37:54 +0000 (14:37 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 16 May 2012 12:37:54 +0000 (14:37 +0200)
Misc/NEWS
Modules/_bisectmodule.c
Objects/rangeobject.c

index 9b9ca674c3a3ac0f4770ed42c7e75407bcc83166..08d21f78b695a51c347a705d1819e0e6f0f252aa 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -63,6 +63,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #14829: Fix bisect and range() indexing with large indices
+  (>= 2 ** 32) under 64-bit Windows.
+
 - Issue #14777: tkinter may return undecoded UTF-8 bytes as a string when
   accessing the Tk clipboard.  Modify clipboad_get() to first request type
   UTF8_STRING when no specific type is requested in an X11 windowing
index 93d0eed41e4a173fcdf367eff2a5f9d79934d261..eae29784dc61d663a56bdda11b2704dcb8a4f252 100644 (file)
@@ -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
@@ -192,7 +193,7 @@ insort_left(PyObject *self, PyObject *args, PyObject *kw)
         if (PyList_Insert(list, index, item) < 0)
             return NULL;
     } else {
-        result = PyObject_CallMethod(list, "insert", "iO", index, item);
+        result = PyObject_CallMethod(list, "insert", "nO", index, item);
         if (result == NULL)
             return NULL;
         Py_DECREF(result);
index 58d373c0b917738b04bcd5bf4bd94c0918ed0b01..935b205111aa75cfba7e11b7dc3136bf63bf982c 100644 (file)
@@ -307,7 +307,7 @@ compute_range_item(rangeobject *r, PyObject *arg)
 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;
     }