[Numpy-svn] r8189 - trunk/numpy/core/src/multiarray

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 12:20:27 CST 2010


Author: ptvirtan
Date: 2010-02-20 12:20:27 -0600 (Sat, 20 Feb 2010)
New Revision: 8189

Modified:
   trunk/numpy/core/src/multiarray/mapping.c
Log:
BUG: fix a crash due to mixing PyUnicode and PyString

Modified: trunk/numpy/core/src/multiarray/mapping.c
===================================================================
--- trunk/numpy/core/src/multiarray/mapping.c	2010-02-20 18:20:10 UTC (rev 8188)
+++ trunk/numpy/core/src/multiarray/mapping.c	2010-02-20 18:20:27 UTC (rev 8189)
@@ -543,6 +543,8 @@
     PyObject *obj;
 
     if (PyString_Check(op) || PyUnicode_Check(op)) {
+        PyObject *temp;
+
         if (self->descr->names) {
             obj = PyDict_GetItem(self->descr->fields, op);
             if (obj != NULL) {
@@ -557,9 +559,16 @@
             }
         }
 
+        temp = op;
+        if (PyUnicode_Check(op)) {
+            temp = PyUnicode_AsUnicodeEscapeString(op);
+        }
         PyErr_Format(PyExc_ValueError,
                      "field named %s not found.",
-                     PyString_AsString(op));
+                     PyBytes_AsString(temp));
+        if (temp != op) {
+            Py_DECREF(temp);
+        }
         return NULL;
     }
 



More information about the Numpy-svn mailing list