[Numpy-svn] r3227 - in trunk/numpy: core/src numarray

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Sep 28 06:20:58 CDT 2006


Author: cookedm
Date: 2006-09-28 06:20:52 -0500 (Thu, 28 Sep 2006)
New Revision: 3227

Modified:
   trunk/numpy/core/src/arraymethods.c
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/arraytypes.inc.src
   trunk/numpy/core/src/scalartypes.inc.src
   trunk/numpy/core/src/ufuncobject.c
   trunk/numpy/numarray/_capi.c
Log:
Python 2.5 fixes: replace int with Py_ssize_t where appropiate


Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c	2006-09-28 10:06:08 UTC (rev 3226)
+++ trunk/numpy/core/src/arraymethods.c	2006-09-28 11:20:52 UTC (rev 3227)
@@ -905,7 +905,8 @@
 	else if (PyDescr_HASFIELDS(dtype)) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
  			if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
 					      &title)) return;
@@ -1080,7 +1081,7 @@
 	int fortran;
 	PyObject *rawdata;
 	char *datastr;
-	int len;
+	Py_ssize_t len;
 	intp size, dimensions[MAX_DIMS];
 	int nd;
 

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-09-28 10:06:08 UTC (rev 3226)
+++ trunk/numpy/core/src/arrayobject.c	2006-09-28 11:20:52 UTC (rev 3227)
@@ -163,7 +163,8 @@
         else if (PyDescr_HASFIELDS(descr)) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 while (PyDict_Next(descr->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                               &title)) return;
@@ -190,7 +191,8 @@
         else if PyDescr_HASFIELDS(descr) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 while (PyDict_Next(descr->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                               &title)) return;
@@ -4521,7 +4523,7 @@
                 PyObject *res=NULL, *temp, *a, *b;
                 PyObject *key, *value, *temp2;
                 PyObject *op;
-                int pos=0;
+                Py_ssize_t pos=0;
                 op = (cmp_op == Py_EQ ? n_ops.logical_and : n_ops.logical_or);
                 while (PyDict_Next(self->descr->fields, &pos, &key, &value)) {
                         a = PyArray_EnsureAnyArray(array_subscript(self, key));
@@ -5390,7 +5392,8 @@
         else if (PyDescr_HASFIELDS(dtype)) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                               &title)) return;
@@ -5566,7 +5569,8 @@
         if (PyDescr_HASFIELDS(dtype)) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                               &title)) return;
@@ -6601,7 +6605,7 @@
 
 
 static PyObject *
-array_alloc(PyTypeObject *type, int nitems)
+array_alloc(PyTypeObject *type, Py_ssize_t nitems)
 {
         PyObject *obj;
         /* nitems will always be 0 */
@@ -10674,7 +10678,8 @@
         else {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 while(PyDict_Next(self->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                               &title)) return -1;
@@ -10864,7 +10869,8 @@
         if (PyDescr_HASFIELDS(self)) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 while (PyDict_Next(self->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                               &title)) {
@@ -11025,7 +11031,8 @@
                 PyObject *newvalue;
                 PyObject *old;
                 PyArray_Descr *newdescr;
-                int pos = 0, len, i;
+                Py_ssize_t pos = 0;
+                int len, i;
                 newfields = PyDict_New();
                 /* make new dictionary with replaced */
                 /* PyArray_Descr Objects */

Modified: trunk/numpy/core/src/arraytypes.inc.src
===================================================================
--- trunk/numpy/core/src/arraytypes.inc.src	2006-09-28 10:06:08 UTC (rev 3226)
+++ trunk/numpy/core/src/arraytypes.inc.src	2006-09-28 11:20:52 UTC (rev 3227)
@@ -333,7 +333,7 @@
 STRING_setitem(PyObject *op, char *ov, PyArrayObject *ap)
 {
         char *ptr;
-        int len;
+        Py_ssize_t len;
         PyObject *temp=NULL;
 
         if (!PyString_Check(op) && !PyUnicode_Check(op) && 
@@ -1250,7 +1250,8 @@
         if (PyArray_HASFIELDS(arr)) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new, *descr;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 descr = arr->descr;
                 while (PyDict_Next(descr->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
@@ -1278,7 +1279,8 @@
         if (PyArray_HASFIELDS(arr)) {
                 PyObject *key, *value, *title=NULL;
                 PyArray_Descr *new, *descr;
-                int offset, pos=0;
+                int offset;
+                Py_ssize_t pos=0;
                 descr = arr->descr;  /* Save it */
                 while (PyDict_Next(descr->fields, &pos, &key, &value)) {
                         if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
@@ -1500,7 +1502,8 @@
         if (PyArray_HASFIELDS(ap)) {
                 PyArray_Descr *descr, *new;
                 PyObject *key, *value, *title;
-                int savedflags, offset, pos=0;
+                int savedflags, offset;
+                Py_ssize_t pos=0;
                 descr = ap->descr;
                 savedflags = ap->flags;
                 while (PyDict_Next(descr->fields, &pos, &key, &value)) {

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2006-09-28 10:06:08 UTC (rev 3226)
+++ trunk/numpy/core/src/scalartypes.inc.src	2006-09-28 11:20:52 UTC (rev 3227)
@@ -275,7 +275,7 @@
 
 
 static PyObject *
-gentype_alloc(PyTypeObject *type, int nitems)
+gentype_alloc(PyTypeObject *type, Py_ssize_t nitems)
 {
         PyObject *obj;
         const size_t size = _PyObject_VAR_SIZE(type, nitems+1);
@@ -1080,8 +1080,8 @@
         return self;
 }
 
-static int
-gentype_getreadbuf(PyObject *, int, void **);
+static Py_ssize_t
+gentype_getreadbuf(PyObject *, Py_ssize_t, void **);
 
 static PyObject *
 gentype_byteswap(PyObject *self, PyObject *args)
@@ -1596,8 +1596,8 @@
 
 
 
-static int
-gentype_getreadbuf(PyObject *self, int segment, void **ptrptr)
+static Py_ssize_t
+gentype_getreadbuf(PyObject *self, Py_ssize_t segment, void **ptrptr)
 {
         int numbytes;
         PyArray_Descr *outcode;
@@ -1616,8 +1616,8 @@
         return numbytes;
 }
 
-static int
-gentype_getsegcount(PyObject *self, int *lenp)
+static Py_ssize_t
+gentype_getsegcount(PyObject *self, Py_ssize_t *lenp)
 {
         PyArray_Descr *outcode;
 
@@ -1628,8 +1628,8 @@
         return 1;
 }
 
-static int
-gentype_getcharbuf(PyObject *self, int segment, constchar **ptrptr)
+static Py_ssize_t
+gentype_getcharbuf(PyObject *self, Py_ssize_t segment, constchar **ptrptr)
 {
         if (PyArray_IsScalar(self, String) ||   \
             PyArray_IsScalar(self, Unicode))
@@ -1644,10 +1644,10 @@
 
 
 static PyBufferProcs gentype_as_buffer = {
-        (getreadbufferproc)gentype_getreadbuf,    /*bf_getreadbuffer*/
-        (getwritebufferproc)0,                    /*bf_getwritebuffer*/
-        (getsegcountproc)gentype_getsegcount,     /*bf_getsegcount*/
-        (getcharbufferproc)gentype_getcharbuf,      /*bf_getcharbuffer*/
+        gentype_getreadbuf,    /*bf_getreadbuffer*/
+        NULL,                 /*bf_getwritebuffer*/
+        gentype_getsegcount,     /*bf_getsegcount*/
+        gentype_getcharbuf,    /*bf_getcharbuffer*/
 };
 
 
@@ -2133,7 +2133,7 @@
 static Py_ssize_t
 object_arrtype_getsegcount(PyObjectScalarObject *self, Py_ssize_t *lenp)
 {
-        int newlen;
+        Py_ssize_t newlen;
         int cnt;
         PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer;
 

Modified: trunk/numpy/core/src/ufuncobject.c
===================================================================
--- trunk/numpy/core/src/ufuncobject.c	2006-09-28 10:06:08 UTC (rev 3226)
+++ trunk/numpy/core/src/ufuncobject.c	2006-09-28 11:20:52 UTC (rev 3227)
@@ -2958,7 +2958,7 @@
         PyUFunc_PyFuncData *fdata;
         PyUFuncObject *self;
         char *fname, *str;
-        int fname_len=-1;
+        Py_ssize_t fname_len=-1;
 	int offset[2];
 
         if (!PyArg_ParseTuple(args, "Oii", &function, &nin, &nout)) return NULL;

Modified: trunk/numpy/numarray/_capi.c
===================================================================
--- trunk/numpy/numarray/_capi.c	2006-09-28 10:06:08 UTC (rev 3226)
+++ trunk/numpy/numarray/_capi.c	2006-09-28 11:20:52 UTC (rev 3227)
@@ -123,7 +123,7 @@
 static int 
 getBufferSize(PyObject *buffobj) 
 {
-  int segcount, size=0;
+  Py_ssize_t segcount, size=0;
   PyObject *buff2;
   if ((buff2 = getBuffer(buffobj))) 
     {



More information about the Numpy-svn mailing list