[Numpy-svn] r5383 - branches/1.1.x/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Jul 9 22:48:13 EDT 2008


Author: charris
Date: 2008-07-09 21:48:10 -0500 (Wed, 09 Jul 2008)
New Revision: 5383

Modified:
   branches/1.1.x/numpy/core/src/multiarraymodule.c
   branches/1.1.x/numpy/core/src/scalartypes.inc.src
Log:
Backport r5361 and r5362.


Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c
===================================================================
--- branches/1.1.x/numpy/core/src/multiarraymodule.c	2008-07-09 20:49:40 UTC (rev 5382)
+++ branches/1.1.x/numpy/core/src/multiarraymodule.c	2008-07-10 02:48:10 UTC (rev 5383)
@@ -2139,12 +2139,18 @@
     if (scalar == PyArray_NOSCALAR) {
         return PyArray_CanCastSafely(thistype, neededtype);
     }
+
     from = PyArray_DescrFromType(thistype);
     if (from->f->cancastscalarkindto &&
         (castlist = from->f->cancastscalarkindto[scalar])) {
         while (*castlist != PyArray_NOTYPE)
-            if (*castlist++ == neededtype) return 1;
+	    if (*castlist++ == neededtype) {
+		Py_DECREF(from);
+		return 1;
+	    }
     }
+    Py_DECREF(from);
+
     switch(scalar) {
     case PyArray_BOOL_SCALAR:
     case PyArray_OBJECT_SCALAR:

Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src
===================================================================
--- branches/1.1.x/numpy/core/src/scalartypes.inc.src	2008-07-09 20:49:40 UTC (rev 5382)
+++ branches/1.1.x/numpy/core/src/scalartypes.inc.src	2008-07-10 02:48:10 UTC (rev 5383)
@@ -1830,7 +1830,10 @@
         if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL;
 
         typecode = PyArray_DescrFromType(PyArray_ at TYPE@);
-        Py_INCREF(typecode);
+        /*
+         * typecode is new reference and stolen by
+         * PyArray_Scalar and others
+         */
         if (obj == NULL) {
 #if @default@ == 0
                 char *mem;




More information about the Numpy-svn mailing list