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

numpy-svn@scip... numpy-svn@scip...
Sat Jun 21 20:23:33 CDT 2008


Author: charris
Date: 2008-06-21 20:23:31 -0500 (Sat, 21 Jun 2008)
New Revision: 5308

Modified:
   trunk/numpy/core/src/ufuncobject.c
Log:
Small code cleanup.
Added commented out alternate TypeError return in ufunc_generic_call.


Modified: trunk/numpy/core/src/ufuncobject.c
===================================================================
--- trunk/numpy/core/src/ufuncobject.c	2008-06-22 01:15:05 UTC (rev 5307)
+++ trunk/numpy/core/src/ufuncobject.c	2008-06-22 01:23:31 UTC (rev 5308)
@@ -1795,7 +1795,7 @@
         PyErr_SetString(PyExc_ValueError, "function not supported");
         return NULL;
     }
-    if ((loop = _pya_malloc(sizeof(PyUFuncLoopObject)))==NULL) {
+    if ((loop = _pya_malloc(sizeof(PyUFuncLoopObject))) == NULL) {
         PyErr_NoMemory();
         return loop;
     }
@@ -1814,30 +1814,30 @@
 
     name = self->name ? self->name : "";
 
-    /* Extract sig= keyword and
-       extobj= keyword if present
-       Raise an error if anything else present in the keyword dictionary
-    */
+    /*
+     * Extract sig= keyword and extobj= keyword if present.
+     * Raise an error if anything else is present in the
+     * keyword dictionary
+     */
     if (kwds != NULL) {
         PyObject *key, *value;
         Py_ssize_t pos=0;
         while (PyDict_Next(kwds, &pos, &key, &value)) {
-            if (!PyString_Check(key)) {
-                PyErr_SetString(PyExc_TypeError,
-                                "invalid keyword");
+            char *keystring = PyString_AsString(key);
+            if (keystring == NULL) {
+                PyErr_Clear();
+                PyErr_SetString(PyExc_TypeError, "invalid keyword");
                 goto fail;
             }
-            if (strncmp(PyString_AS_STRING(key),"extobj",6) == 0) {
+            if (strncmp(keystring,"extobj",6) == 0) {
                 extobj = value;
             }
-            else if (strncmp(PyString_AS_STRING(key),"sig",5)==0) {
+            else if (strncmp(keystring,"sig",3) == 0) {
                 typetup = value;
             }
             else {
-                PyErr_Format(PyExc_TypeError,
-                             "'%s' is an invalid keyword " \
-                             "to %s",
-                             PyString_AS_STRING(key), name);
+                char *format = "'%s' is an invalid keyword to %s";
+                PyErr_Format(PyExc_TypeError,format,keystring, name);
                 goto fail;
             }
         }
@@ -3321,6 +3321,10 @@
         if (errval == -1)
             return NULL;
         else {
+            /*
+             * PyErr_SetString(PyExc_TypeError,"");
+             * return NULL;
+             */
             Py_INCREF(Py_NotImplemented);
             return Py_NotImplemented;
         }



More information about the Numpy-svn mailing list