[Numpy-svn] r8286 - trunk/numpy/f2py

numpy-svn@scip... numpy-svn@scip...
Sat Mar 6 17:59:23 CST 2010


Author: ptvirtan
Date: 2010-03-06 17:59:22 -0600 (Sat, 06 Mar 2010)
New Revision: 8286

Modified:
   trunk/numpy/f2py/cfuncs.py
Log:
BUG: f2py: fix infinite loops in *_from_pyobj with unicode input

Modified: trunk/numpy/f2py/cfuncs.py
===================================================================
--- trunk/numpy/f2py/cfuncs.py	2010-03-06 23:59:08 UTC (rev 8285)
+++ trunk/numpy/f2py/cfuncs.py	2010-03-06 23:59:22 UTC (rev 8286)
@@ -689,7 +689,7 @@
 \t}
 \tif (PyComplex_Check(obj))
 \t\ttmp = PyObject_GetAttrString(obj,\"real\");
-\telse if (PyString_Check(obj))
+\telse if (PyString_Check(obj) || PyUnicode_Check(obj))
 \t\t/*pass*/;
 \telse if (PySequence_Check(obj))
 \t\ttmp = PySequence_GetItem(obj,0);
@@ -721,7 +721,7 @@
 \t}
 \tif (PyComplex_Check(obj))
 \t\ttmp = PyObject_GetAttrString(obj,\"real\");
-\telse if (PyString_Check(obj))
+\telse if (PyString_Check(obj) || PyUnicode_Check(obj))
 \t\t/*pass*/;
 \telse if (PySequence_Check(obj))
 \t\ttmp = PySequence_GetItem(obj,0);
@@ -758,7 +758,7 @@
 \t}
 \tif (PyComplex_Check(obj))
 \t\ttmp = PyObject_GetAttrString(obj,\"real\");
-\telse if (PyString_Check(obj))
+\telse if (PyString_Check(obj) || PyUnicode_Check(obj))
 \t\t/*pass*/;
 \telse if (PySequence_Check(obj))
 \t\ttmp = PySequence_GetItem(obj,0);
@@ -819,7 +819,7 @@
 \t}
 \tif (PyComplex_Check(obj))
 \t\ttmp = PyObject_GetAttrString(obj,\"real\");
-\telse if (PyString_Check(obj))
+\telse if (PyString_Check(obj) || PyUnicode_Check(obj))
 \t\t/*pass*/;
 \telse if (PySequence_Check(obj))
 \t\ttmp = PySequence_GetItem(obj,0);
@@ -929,7 +929,7 @@
 \t\t(*v).r = PyLong_AsDouble(obj);
 \t\treturn (!PyErr_Occurred());
 \t}
-\tif (PySequence_Check(obj) && (!PyString_Check(obj))) {
+\tif (PySequence_Check(obj) && !(PyString_Check(obj) || PyUnicode_Check(obj))) {
 \t\tPyObject *tmp = PySequence_GetItem(obj,0);
 \t\tif (tmp) {
 \t\t\tif (complex_double_from_pyobj(v,tmp,errmess)) {



More information about the Numpy-svn mailing list