[Numpy-svn] r3810 - trunk/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Wed May 23 16:25:36 EDT 2007


Author: oliphant
Date: 2007-05-23 15:25:31 -0500 (Wed, 23 May 2007)
New Revision: 3810

Modified:
   trunk/numpy/core/src/arraymethods.c
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/multiarraymodule.c
   trunk/numpy/core/src/scalartypes.inc.src
Log:
Properly decrement references for _internal.py imports

Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c	2007-05-23 19:30:18 UTC (rev 3809)
+++ trunk/numpy/core/src/arraymethods.c	2007-05-23 20:25:31 UTC (rev 3810)
@@ -883,6 +883,7 @@
                 if (_numpy_internal == NULL) return NULL;
                 new_name = PyObject_CallMethod(_numpy_internal, "_newnames",
                                                "OO", saved, order);
+                Py_DECREF(_numpy_internal);
                 if (new_name == NULL) return NULL;
                 newd = PyArray_DescrNew(saved);
                 newd->names = new_name;
@@ -928,6 +929,7 @@
                 if (_numpy_internal == NULL) return NULL;
                 new_name = PyObject_CallMethod(_numpy_internal, "_newnames",
                                                "OO", saved, order);
+                Py_DECREF(_numpy_internal);
                 if (new_name == NULL) return NULL;
                 newd = PyArray_DescrNew(saved);
                 newd->names = new_name;

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2007-05-23 19:30:18 UTC (rev 3809)
+++ trunk/numpy/core/src/arrayobject.c	2007-05-23 20:25:31 UTC (rev 3810)
@@ -6132,11 +6132,14 @@
 array_ctypes_get(PyArrayObject *self)
 {
         PyObject *_numpy_internal;
+        PyObject *ret;
         _numpy_internal = PyImport_ImportModule("numpy.core._internal");
         if (_numpy_internal == NULL) return NULL;
-        return PyObject_CallMethod(_numpy_internal, "_ctypes",
-                                   "ON", self,
-                                   PyLong_FromVoidPtr(self->data));
+        ret = PyObject_CallMethod(_numpy_internal, "_ctypes",
+                                  "ON", self,
+                                  PyLong_FromVoidPtr(self->data));
+        Py_DECREF(_numpy_internal);
+        return ret;
 }
 
 static PyObject *
@@ -10864,8 +10867,10 @@
 
         _numpy_internal = PyImport_ImportModule("numpy.core._internal");
         if (_numpy_internal == NULL) return NULL;
-        return PyObject_CallMethod(_numpy_internal, "_array_descr",
-                                   "O", self);
+        res = PyObject_CallMethod(_numpy_internal, "_array_descr",
+                                  "O", self);
+        Py_DECREF(_numpy_internal);
+        return res;
 }
 
 /* returns 1 for a builtin type

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2007-05-23 19:30:18 UTC (rev 3809)
+++ trunk/numpy/core/src/multiarraymodule.c	2007-05-23 20:25:31 UTC (rev 3810)
@@ -26,6 +26,7 @@
         
 
 static PyObject *typeDict=NULL;   /* Must be explicitly loaded */
+static PyObject *_internal_pname=NULL;
 
 static PyArray_Descr *
 _arraydescr_fromobj(PyObject *obj)
@@ -4866,6 +4867,7 @@
         if (_numpy_internal == NULL) return NULL;
         listobj = PyObject_CallMethod(_numpy_internal, "_commastring",
 				      "O", obj);
+        Py_DECREF(_numpy_internal);
 	if (!listobj) return NULL;
 	if (!PyList_Check(listobj) || PyList_GET_SIZE(listobj)<1) {
 		PyErr_SetString(PyExc_RuntimeError, "_commastring is "	\
@@ -4929,12 +4931,14 @@
 static PyArray_Descr *
 _use_fields_dict(PyObject *obj, int align)
 {
-        PyObject *_numpy_internal;
+        PyObject *_numpy_internal, *res;
         _numpy_internal = PyImport_ImportModule("numpy.core._internal");
         if (_numpy_internal == NULL) return NULL;
-        return (PyArray_Descr *)PyObject_CallMethod(_numpy_internal,
-						    "_usefields",
-						    "Oi", obj, align);
+        res = (PyArray_Descr *)PyObject_CallMethod(_numpy_internal,
+                                                   "_usefields",
+                                                   "Oi", obj, align);
+        Py_DECREF(_numpy_internal);
+        return res;
 }
 
 static PyArray_Descr *

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2007-05-23 19:30:18 UTC (rev 3809)
+++ trunk/numpy/core/src/scalartypes.inc.src	2007-05-23 20:25:31 UTC (rev 3810)
@@ -2671,6 +2671,7 @@
         _numpy_internal = PyImport_ImportModule("numpy.core._internal");
         if (_numpy_internal == NULL) return NULL;
         tup = PyObject_CallMethod(_numpy_internal, "_makenames_list", "O", fields);
+        Py_DECREF(_numpy_internal);
         if (tup == NULL) return NULL;
         ret = PyTuple_GET_ITEM(tup, 0);
         ret = PySequence_Tuple(ret);




More information about the Numpy-svn mailing list