diff options
Diffstat (limited to 'numpy/f2py/cfuncs.py')
-rw-r--r-- | numpy/f2py/cfuncs.py | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index f403a66b5..4e53344ec 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -763,20 +763,26 @@ int_from_pyobj(int* v, PyObject *obj, const char *errmess) return !(*v == -1 && PyErr_Occurred()); } - if (PyComplex_Check(obj)) + if (PyComplex_Check(obj)) { + PyErr_Clear(); tmp = PyObject_GetAttrString(obj,\"real\"); - else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) + } + else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) { /*pass*/; - else if (PySequence_Check(obj)) + } + else if (PySequence_Check(obj)) { + PyErr_Clear(); tmp = PySequence_GetItem(obj, 0); + } + if (tmp) { - PyErr_Clear(); if (int_from_pyobj(v, tmp, errmess)) { Py_DECREF(tmp); return 1; } Py_DECREF(tmp); } + { PyObject* err = PyErr_Occurred(); if (err == NULL) { @@ -806,15 +812,19 @@ long_from_pyobj(long* v, PyObject *obj, const char *errmess) { return !(*v == -1 && PyErr_Occurred()); } - if (PyComplex_Check(obj)) + if (PyComplex_Check(obj)) { + PyErr_Clear(); tmp = PyObject_GetAttrString(obj,\"real\"); - else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) + } + else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) { /*pass*/; - else if (PySequence_Check(obj)) - tmp = PySequence_GetItem(obj,0); + } + else if (PySequence_Check(obj)) { + PyErr_Clear(); + tmp = PySequence_GetItem(obj, 0); + } if (tmp) { - PyErr_Clear(); if (long_from_pyobj(v, tmp, errmess)) { Py_DECREF(tmp); return 1; @@ -852,14 +862,19 @@ long_long_from_pyobj(long_long* v, PyObject *obj, const char *errmess) return !(*v == -1 && PyErr_Occurred()); } - if (PyComplex_Check(obj)) + if (PyComplex_Check(obj)) { + PyErr_Clear(); tmp = PyObject_GetAttrString(obj,\"real\"); - else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) + } + else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) { /*pass*/; - else if (PySequence_Check(obj)) - tmp = PySequence_GetItem(obj,0); - if (tmp) { + } + else if (PySequence_Check(obj)) { PyErr_Clear(); + tmp = PySequence_GetItem(obj, 0); + } + + if (tmp) { if (long_long_from_pyobj(v, tmp, errmess)) { Py_DECREF(tmp); return 1; @@ -919,14 +934,20 @@ double_from_pyobj(double* v, PyObject *obj, const char *errmess) Py_DECREF(tmp); return !(*v == -1.0 && PyErr_Occurred()); } - if (PyComplex_Check(obj)) + + if (PyComplex_Check(obj)) { + PyErr_Clear(); tmp = PyObject_GetAttrString(obj,\"real\"); - else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) + } + else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) { /*pass*/; - else if (PySequence_Check(obj)) - tmp = PySequence_GetItem(obj,0); - if (tmp) { + } + else if (PySequence_Check(obj)) { PyErr_Clear(); + tmp = PySequence_GetItem(obj, 0); + } + + if (tmp) { if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} Py_DECREF(tmp); } |