From 80f6b2a2ceb7981c292fd3071f5d2eba1c9866ab Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 6 Mar 2010 23:59:22 +0000 Subject: BUG: f2py: fix infinite loops in *_from_pyobj with unicode input --- numpy/f2py/cfuncs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'numpy/f2py') diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index 45f622700..74a0ab363 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -689,7 +689,7 @@ static int int_from_pyobj(int* v,PyObject *obj,const char *errmess) { \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 @@ static int long_from_pyobj(long* v,PyObject *obj,const char *errmess) { \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 @@ static int long_long_from_pyobj(long_long* v,PyObject *obj,const char *errmess) \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 @@ static int double_from_pyobj(double* v,PyObject *obj,const char *errmess) { \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 @@ static int complex_double_from_pyobj(complex_double* v,PyObject *obj,const char \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)) { -- cgit v1.2.1