summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-02-16 14:30:23 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-02-16 14:30:23 (GMT)
commitad0a4629beac0600c4c4c3167b0d68be57ca674e (patch)
treea4aef28fd7dbf93c7dabde51ce88fe1748e29427 /Modules/arraymodule.c
parent97c65a8068056863215eb3a14024c1e4a8d19b9f (diff)
downloadcpython-ad0a4629beac0600c4c4c3167b0d68be57ca674e.zip
cpython-ad0a4629beac0600c4c4c3167b0d68be57ca674e.tar.gz
cpython-ad0a4629beac0600c4c4c3167b0d68be57ca674e.tar.bz2
Use Py_ssize_t for counts and sizes.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 704b745..9444e9e 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -688,11 +688,11 @@ array_repeat(arrayobject *a, Py_ssize_t n)
}
static int
-array_ass_slice(arrayobject *a, int ilow, int ihigh, PyObject *v)
+array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
{
char *item;
- int n; /* Size of replacement array */
- int d; /* Change in size */
+ Py_ssize_t n; /* Size of replacement array */
+ Py_ssize_t d; /* Change in size */
#define b ((arrayobject *)v)
if (v == NULL)
n = 0;
@@ -907,10 +907,7 @@ array_count(arrayobject *self, PyObject *v)
else if (cmp < 0)
return NULL;
}
- if (i < LONG_MAX)
- return PyInt_FromLong((long)count);
- else
- return PyLong_FromLong(count);
+ return PyInt_FromSsize_t(count);
}
PyDoc_STRVAR(count_doc,
@@ -987,9 +984,9 @@ Remove the first occurence of x in the array.");
static PyObject *
array_pop(arrayobject *self, PyObject *args)
{
- int i = -1;
+ Py_ssize_t i = -1;
PyObject *v;
- if (!PyArg_ParseTuple(args, "|i:pop", &i))
+ if (!PyArg_ParseTuple(args, "|n:pop", &i))
return NULL;
if (self->ob_size == 0) {
/* Special-case most common failure cause */
@@ -1196,7 +1193,7 @@ static PyObject *
array_fromfile(arrayobject *self, PyObject *args)
{
PyObject *f;
- int n;
+ Py_ssize_t n;
FILE *fp;
if (!PyArg_ParseTuple(args, "Oi:fromfile", &f, &n))
return NULL;
@@ -1207,9 +1204,9 @@ array_fromfile(arrayobject *self, PyObject *args)
}
if (n > 0) {
char *item = self->ob_item;
- int itemsize = self->ob_descr->itemsize;
+ Py_ssize_t itemsize = self->ob_descr->itemsize;
size_t nread;
- int newlength;
+ Py_ssize_t newlength;
size_t newbytes;
/* Be careful here about overflow */
if ((newlength = self->ob_size + n) <= 0 ||
@@ -1577,13 +1574,13 @@ static PyObject*
array_subscr(arrayobject* self, PyObject* item)
{
if (PyInt_Check(item)) {
- long i = PyInt_AS_LONG(item);
+ Py_ssize_t i = PyInt_AS_LONG(item);
if (i < 0)
i += self->ob_size;
return array_item(self, i);
}
else if (PyLong_Check(item)) {
- long i = PyLong_AsLong(item);
+ Py_ssize_t i = PyInt_AsSsize_t(item);
if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
@@ -1631,13 +1628,13 @@ static int
array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
{
if (PyInt_Check(item)) {
- long i = PyInt_AS_LONG(item);
+ Py_ssize_t i = PyInt_AS_LONG(item);
if (i < 0)
i += self->ob_size;
return array_ass_item(self, i, value);
}
else if (PyLong_Check(item)) {
- long i = PyLong_AsLong(item);
+ Py_ssize_t i = PyInt_AsSsize_t(item);
if (i == -1 && PyErr_Occurred())
return -1;
if (i < 0)