summaryrefslogtreecommitdiff
path: root/numpy/f2py/cfuncs.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/f2py/cfuncs.py')
-rw-r--r--numpy/f2py/cfuncs.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py
index 741692562..2d27b6524 100644
--- a/numpy/f2py/cfuncs.py
+++ b/numpy/f2py/cfuncs.py
@@ -800,16 +800,23 @@ character_from_pyobj(character* v, PyObject *obj, const char *errmess) {
}
}
{
+ /* TODO: This error (and most other) error handling needs cleaning. */
char mess[F2PY_MESSAGE_BUFFER_SIZE];
strcpy(mess, errmess);
PyObject* err = PyErr_Occurred();
if (err == NULL) {
err = PyExc_TypeError;
+ Py_INCREF(err);
+ }
+ else {
+ Py_INCREF(err);
+ PyErr_Clear();
}
sprintf(mess + strlen(mess),
" -- expected str|bytes|sequence-of-str-or-bytes, got ");
f2py_describe(obj, mess + strlen(mess));
PyErr_SetString(err, mess);
+ Py_DECREF(err);
}
return 0;
}
@@ -1227,8 +1234,8 @@ static int try_pyarr_from_character(PyObject* obj, character* v) {
strcpy(mess, "try_pyarr_from_character failed"
" -- expected bytes array-scalar|array, got ");
f2py_describe(obj, mess + strlen(mess));
+ PyErr_SetString(err, mess);
}
- PyErr_SetString(err, mess);
}
return 0;
}