Skip to content

Commit

Permalink
Issue python#14829: Fix bisect and range() indexing with large indice…
Browse files Browse the repository at this point in the history
…s (>= 2 ** 32) under 64-bit Windows.

(untested, because of Windows build issues under 3.x)
  • Loading branch information
pitrou committed May 16, 2012
2 parents b84bc7a + a103b96 commit b7d033d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Core and Builtins
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.

Expand Down
4 changes: 2 additions & 2 deletions Modules/_bisectmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -195,8 +196,7 @@ insort_left(PyObject *self, PyObject *args, PyObject *kw)
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);
Expand Down
2 changes: 1 addition & 1 deletion Objects/rangeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,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;
}
Expand Down

0 comments on commit b7d033d

Please sign in to comment.