File python-numeric-24.2-pep353.diff of Package python-numeric
--- Src/arrayobject.c
+++ Src/arrayobject.c
@@ -491,7 +491,8 @@
static PyObject * PyArray_Resize(PyArrayObject *self, PyObject *shape) {
size_t oldsize, newsize;
- int new_nd, k, sd, n, elsize;
+ int sd, n, elsize;
+ Py_ssize_t new_nd, k;
int refcnt;
int new_dimensions[MAX_DIMS];
int new_strides[MAX_DIMS];
@@ -776,7 +777,7 @@
if ((item = index2ptr(self, i)) == NULL) return -1;
- if(self->descr->type_num != PyArray_OBJECT && PyString_Check(v) && PyObject_Length(v) == 1) {
+ if(self->descr->type_num != PyArray_OBJECT && PyString_Check(v) && PyObject_Length(v) == (Py_ssize_t)1) {
char *s;
if ((s=PyString_AsString(v)) == NULL) return -1;
if(self->descr->type == 'c') {
@@ -823,7 +824,7 @@
/* This is basically PySlice_GetIndicesEx, but with our coercion
* of indices to integers (plus, that function is new in Python 2.3) */
-static int
+static Py_ssize_t
slice_GetIndices(PySliceObject *r, int length,
int *start, int *stop, int *step,
int *slicelength)
@@ -925,8 +926,8 @@
static int parse_index(PyArrayObject *self, PyObject *op,
int *dimensions, int *strides, int *offset_ptr) {
- int i, j, n;
- int nd_old, nd_new, start, offset, n_add, n_pseudo;
+ Py_ssize_t i, n, j, n_add, n_pseudo;
+ int nd_old, nd_new, start, offset;
int step_size, n_steps;
PyObject *op1=NULL;
int is_slice;
@@ -1098,7 +1099,7 @@
}
static PyMappingMethods array_as_mapping = {
- (inquiry)array_length, /*mp_length*/
+ (lenfunc)array_length, /*mp_length*/
(binaryfunc)array_subscript_nice, /*mp_subscript*/
(objobjargproc)array_ass_sub, /*mp_ass_subscript*/
};
@@ -1183,10 +1184,10 @@
}
static PyBufferProcs array_as_buffer = {
- (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/
- (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/
- (getsegcountproc)array_getsegcount, /*bf_getsegcount*/
- (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/
+ (readbufferproc)array_getreadbuf, /*bf_getreadbuffer*/
+ (writebufferproc)array_getwritebuf, /*bf_getwritebuffer*/
+ (segcountproc)array_getsegcount, /*bf_getsegcount*/
+ (charbufferproc)array_getcharbuf, /*bf_getcharbuffer*/
};
/* End methods added by Scott N. Gunyan for buffer extension */
@@ -1595,7 +1596,7 @@
(unaryfunc)array_negative,
(unaryfunc)PyArray_Copy, /*nb_pos*/
(unaryfunc)array_absolute, /*(unaryfunc)array_abs,*/
- (inquiry)array_nonzero, /*nb_nonzero*/
+ (lenfunc)array_nonzero, /*nb_nonzero*/
(unaryfunc)array_invert, /*nb_invert*/
(binaryfunc)array_left_shift, /*nb_lshift*/
(binaryfunc)array_right_shift, /*nb_rshift*/
@@ -1634,13 +1635,13 @@
};
static PySequenceMethods array_as_sequence = {
- (inquiry)array_length, /*sq_length*/
+ (lenfunc)array_length, /*sq_length*/
(binaryfunc)NULL, /*nb_add, concat is numeric add*/
- (intargfunc)NULL, /*nb_multiply, repeat is numeric multiply*/
- (intargfunc)array_item_nice, /*sq_item*/
- (intintargfunc)array_slice, /*sq_slice*/
- (intobjargproc)array_ass_item, /*sq_ass_item*/
- (intintobjargproc)array_ass_slice, /*sq_ass_slice*/
+ (ssizeargfunc)NULL, /*nb_multiply, repeat is numeric multiply*/
+ (ssizeargfunc)array_item_nice, /*sq_item*/
+ (ssizessizeargfunc)array_slice, /*sq_slice*/
+ (ssizeobjargproc)array_ass_item, /*sq_ass_item*/
+ (ssizessizeobjargproc)array_ass_slice, /*sq_ass_slice*/
};
/* -------------------------------------------------------------- */
@@ -2428,7 +2429,7 @@
#if PY_VERSION_HEX >= 0x02010000
(traverseproc)0L,
- (inquiry)0L,
+ (lenfunc)0L,
(richcmpfunc)array_richcompare, /*tp_richcompfunc*/
offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */
#endif
@@ -2465,7 +2466,8 @@
static int discover_dimensions(PyObject *s, int nd, int *d, int check_it) {
PyObject *e;
- int r, n, i, n_lower;
+ int r, n_lower;
+ Py_ssize_t i, n;
n=PyObject_Length(s);
*d = n;
@@ -2503,7 +2505,7 @@
static int
array_objecttype(PyObject *op, int minimum_type, int savespaceflag, int max)
{
- int l;
+ Py_ssize_t l;
PyObject *ip;
int result;
PyArray_Descr* descr;
@@ -2595,7 +2597,9 @@
static int Assign_Array(PyArrayObject *self, PyObject *v) {
PyObject *e;
- int l, r;
+ int r;
+ Py_ssize_t l;
+
if (!PySequence_Check(v)) {
PyErr_SetString(PyExc_ValueError,"assignment from non-sequence");
--- Src/multiarraymodule.c
+++ Src/multiarraymodule.c
@@ -36,7 +36,8 @@
extern PyObject *PyArray_Concatenate(PyObject *op) {
PyArrayObject *ret, **mps;
PyObject *otmp;
- int i, n, type_num, tmp, nd=0, new_dim;
+ int type_num, tmp, nd=0, new_dim;
+ Py_ssize_t i, n;
char *data;
n = PySequence_Length(op);
@@ -284,7 +285,8 @@
extern PyObject *PyArray_Choose(PyObject *ip, PyObject *op) {
- int i, n, *sizes, m, offset, elsize, type_num;
+ int *sizes, elsize, type_num;
+ Py_ssize_t i, n, m, offset;
char *ret_data;
PyArrayObject **mps, *ap, *ret;
PyObject *otmp;
@@ -1139,7 +1141,8 @@
static char *kwlist[] = {"shape", "typecode", "savespace", NULL};
PyObject *op;
PyArray_Descr *descr;
- int i, nd, n, dims[MAX_DIMS];
+ int dims[MAX_DIMS];
+ Py_ssize_t i, nd, n;
int sd;
char *data;
@@ -1217,7 +1220,8 @@
PyArrayObject *ret;
char type_char='l';
char *type = &type_char, *dptr;
- int i, nd, n, dimensions[MAX_DIMS];
+ int dimensions[MAX_DIMS];
+ Py_ssize_t i, nd, n;
int savespace=0;
static char all_zero[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static char *kwlist[] = {"shape", "typecode", "savespace", NULL};
--- Src/ufuncobject.c
+++ Src/ufuncobject.c
@@ -272,7 +272,7 @@
int setup_matrices(PyUFuncObject *self, PyObject *args, PyUFuncGenericFunction *function, void **data,
PyArrayObject **mps, char *arg_types) {
- int nargs, i;
+ Py_ssize_t nargs, i;
nargs = PyTuple_Size(args);
if ((nargs != self->nin) && (nargs != self->nin+self->nout)) {