summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-03-14 07:22:32 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-03-14 07:22:32 +0000
commit22335be3938621d9a4ed0ca0ac8ec5a8fc5a1da3 (patch)
tree4b3a34cb20ec9c3eeb467e758985eaf908c74f0f
parent57b603a2cfbd54de0c4ad64194a88b1860955015 (diff)
downloadnumpy-22335be3938621d9a4ed0ca0ac8ec5a8fc5a1da3.tar.gz
Fix missing increment of reference count.
-rw-r--r--numpy/core/blasdot/_dotblas.c4
-rw-r--r--numpy/core/src/arrayobject.c25
-rw-r--r--numpy/doc/CAPI.txt4
3 files changed, 21 insertions, 12 deletions
diff --git a/numpy/core/blasdot/_dotblas.c b/numpy/core/blasdot/_dotblas.c
index 0bad82487..fa15225d2 100644
--- a/numpy/core/blasdot/_dotblas.c
+++ b/numpy/core/blasdot/_dotblas.c
@@ -160,7 +160,7 @@ static PyObject *
dotblas_matrixproduct(PyObject *dummy, PyObject *args)
{
PyObject *op1, *op2;
- PyArrayObject *ap1, *ap2, *ret;
+ PyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;
int j, l, lda, ldb, ldc;
int typenum, nd;
intp ap1stride=0;
@@ -191,10 +191,10 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args)
return PyArray_Return((PyArrayObject *)PyArray_MatrixProduct(op1, op2));
}
- ret = NULL;
dtype = PyArray_DescrFromType(typenum);
ap1 = (PyArrayObject *)PyArray_FromAny(op1, dtype, 0, 0, ALIGNED, NULL);
if (ap1 == NULL) return NULL;
+ Py_INCREF(dtype);
ap2 = (PyArrayObject *)PyArray_FromAny(op2, dtype, 0, 0, ALIGNED, NULL);
if (ap2 == NULL) goto fail;
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index bb6d101cf..aa3d112ce 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -3122,10 +3122,11 @@ static PyNumberMethods array_as_number = {
static PyObject *
-array_slice(PyArrayObject *self, int ilow, int ihigh)
+array_slice(PyArrayObject *self, _int_or_ssize_t ilow,
+ _int_or_ssize_t ihigh)
{
PyArrayObject *r;
- int l;
+ _int_or_ssize_t l;
char *data;
if (self->nd == 0) {
@@ -3166,7 +3167,8 @@ array_slice(PyArrayObject *self, int ilow, int ihigh)
static int
-array_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {
+array_ass_slice(PyArrayObject *self, _int_or_ssize_t ilow,
+ _int_or_ssize_t ihigh, PyObject *v) {
int ret;
PyArrayObject *tmp;
@@ -3207,7 +3209,7 @@ array_contains(PyArrayObject *self, PyObject *el)
static PySequenceMethods array_as_sequence = {
#if PY_VERSION_HEX >= 0x02050000
(lenfunc)array_length, /*sq_length*/
- (binaryfunc)NULL, /* sq_concat is handled by nb_add*/
+ (binaryfunc)NULL, /* sq_concat is handled by nb_add*/
(ssizeargfunc)NULL,
(ssizeargfunc)array_item_nice,
(ssizessizeargfunc)array_slice,
@@ -6808,10 +6810,10 @@ arrayiter_dealloc(PyArrayIterObject *it)
_pya_free(it);
}
-static int
+static _int_or_ssize_t
iter_length(PyArrayIterObject *self)
{
- return (int) self->size;
+ return self->size;
}
@@ -7282,7 +7284,11 @@ iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)
static PyMappingMethods iter_as_mapping = {
+#if PY_VERSION_HEX >= 0x02050000
+ (lenfunc)iter_length, /*mp_length*/
+#else
(inquiry)iter_length, /*mp_length*/
+#endif
(binaryfunc)iter_subscript, /*mp_subscript*/
(objobjargproc)iter_ass_subscript, /*mp_ass_subscript*/
};
@@ -8969,7 +8975,7 @@ arraydescr_compare(PyArray_Descr *self, PyObject *other)
**************** Implement Mapping Protocol ***************************
*************************************************************************/
-static int
+static _int_or_ssize_t
descr_length(PyArray_Descr *self)
{
@@ -9010,12 +9016,15 @@ descr_subscript(PyArray_Descr *self, PyObject *op)
"there are no fields in dtype %s.",
PyString_AsString(arraydescr_str(self)));
}
-
return NULL;
}
static PyMappingMethods descr_as_mapping = {
+#if PY_VERSION_HEX >= 0x02050000
+ (lenfunc)descr_length, /*mp_length*/
+#else
(inquiry)descr_length, /*mp_length*/
+#endif
(binaryfunc)descr_subscript, /*mp_subscript*/
(objobjargproc)NULL, /*mp_ass_subscript*/
};
diff --git a/numpy/doc/CAPI.txt b/numpy/doc/CAPI.txt
index 6d875136f..9286ee050 100644
--- a/numpy/doc/CAPI.txt
+++ b/numpy/doc/CAPI.txt
@@ -13,8 +13,8 @@ of the API) that will need to be changed:
* If you used any of the function pointers in the ``PyArray_Descr``
structure you will have to modify your usage of those. First,
- the pointers are all under the member named ``f``. So ``descr->cast`` is now
- ``descr->f->cast``. In addition, the
+ the pointers are all under the member named ``f``. So ``descr->cast``
+ is now ``descr->f->cast``. In addition, the
casting functions have eliminated the strides argument (use
``PyArray_CastTo`` if you need strided casting). All functions have
one or two ``PyArrayObject *`` arguments at the end. This allows the