From: Kristján Valur Jónsson Date: Mon, 7 May 2007 18:30:48 +0000 (+0000) Subject: Fix two problems that emerged when the testsuite was run with an x64 build: PyLong_F... X-Git-Tag: v2.5.2c1~311 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4601d874fc41cc7aa904ff09b9da273cefd7b72;p=python Fix two problems that emerged when the testsuite was run with an x64 build: PyLong_FromSSize_t incorrectly assumed an unsigned object, and itertools.count() had the wrong upper limit for the iterator. --- diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 70f787f784..31f20c710c 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2073,9 +2073,9 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static PyObject * count_next(countobject *lz) { - if (lz->cnt == LONG_MAX) { + if (lz->cnt == PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, - "cannot count beyond LONG_MAX"); + "cannot count beyond PY_SSIZE_T_MAX"); return NULL; } return PyInt_FromSsize_t(lz->cnt++); diff --git a/Objects/longobject.c b/Objects/longobject.c index 7bf04d2941..e51517f3c8 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -893,7 +893,7 @@ _PyLong_FromSsize_t(Py_ssize_t ival) int one = 1; return _PyLong_FromByteArray( (unsigned char *)&bytes, - SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 0); + SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 1); } /* Create a new long int object from a C size_t. */