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

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Sep 21 10:51:13 CDT 2006


Author: charris
Date: 2006-09-21 10:51:00 -0500 (Thu, 21 Sep 2006)
New Revision: 3203

Modified:
   trunk/numpy/core/src/arraymethods.c
   trunk/numpy/core/src/multiarraymodule.c
Log:
Small changes of searchsorted error messages.

Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c	2006-09-21 07:58:41 UTC (rev 3202)
+++ trunk/numpy/core/src/arraymethods.c	2006-09-21 15:51:00 UTC (rev 3203)
@@ -886,11 +886,12 @@
 static PyObject *
 array_searchsorted(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
+        static char *kwlist[] = {"keys", "side", NULL};
 	PyObject *keys;
-        static char *kwlist[] = {"keys", "side", NULL};
         NPY_SEARCHSIDE side = NPY_SEARCHLEFT;
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&", kwlist, &keys,
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&:searchsorted",
+                                         kwlist, &keys,
                                          PyArray_SearchsideConverter, &side))
                 return NULL;
 

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-09-21 07:58:41 UTC (rev 3202)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-09-21 15:51:00 UTC (rev 3203)
@@ -2609,15 +2609,14 @@
   Convert object to searchsorted side
 */
 static int
-PyArray_SearchsideConverter(PyObject *obj, NPY_SEARCHSIDE *side)
+PyArray_SearchsideConverter(PyObject *obj, void *addr)
 {
+        NPY_SEARCHSIDE *side = (NPY_SEARCHSIDE *)addr;
 	char *str = PyString_AsString(obj);
 
-	if (!str)
-                return PY_FAIL;
-	if (strlen(str) < 1) {
+	if (!str || strlen(str) < 1) {
 		PyErr_SetString(PyExc_ValueError,
-                                "side must be nonempty string");
+                                "expected nonempty string for keyword 'side'");
 		return PY_FAIL;
 	}
 
@@ -2627,7 +2626,7 @@
                 *side = NPY_SEARCHRIGHT;
         else {
 		PyErr_Format(PyExc_ValueError,
-                             "side has invalid value '%s'", str);
+                             "'%s' is an invalid value for keyword 'side'", str);
 		return PY_FAIL;
 	}
 	return PY_SUCCEED;



More information about the Numpy-svn mailing list