From a103b96a80f049f68ccf2dd3d5d7858b26a27e94 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 16 May 2012 14:37:54 +0200 Subject: [PATCH] Issue #14829: Fix bisect and range() indexing with large indices (>= 2 ** 32) under 64-bit Windows. --- Misc/NEWS | 3 +++ Modules/_bisectmodule.c | 3 ++- Objects/rangeobject.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 9b9ca674c3a..08d21f78b69 100644 --- 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 diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c index 93d0eed41e4..eae29784dc6 100644 --- 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 @@ -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); diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 58d373c0b91..935b205111a 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -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; }