summaryrefslogtreecommitdiff
path: root/numpy/f2py/src/fortranobject.c
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2020-01-06 18:57:47 +0000
committerEric Wieser <wieser.eric@gmail.com>2020-01-14 15:06:52 +0000
commite2921434a07c22714bbf242be5389c3056449863 (patch)
treed0272d304ff0cde77a1953d4ec46d82a8b0af453 /numpy/f2py/src/fortranobject.c
parentfbd807f5c5587407847f1aa54e6dada79bb90c35 (diff)
downloadnumpy-e2921434a07c22714bbf242be5389c3056449863.tar.gz
BUG: Use PyDict_GetItemWithError() instead of PyDict_GetItem()
This means we no longer interpret `MemoryError` or `KeyboardInterrupt` as `keyword arg not provided`, for instance. This function is python 3 only, hence this was difficult to do in older versions of numpy. Inspired by https://bugs.python.org/issue35459
Diffstat (limited to 'numpy/f2py/src/fortranobject.c')
-rw-r--r--numpy/f2py/src/fortranobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c
index 8ec5b510f..644339218 100644
--- a/numpy/f2py/src/fortranobject.c
+++ b/numpy/f2py/src/fortranobject.c
@@ -260,8 +260,11 @@ static PyObject *
fortran_getattr(PyFortranObject *fp, char *name) {
int i,j,k,flag;
if (fp->dict != NULL) {
- PyObject *v = PyDict_GetItemString(fp->dict, name);
- if (v != NULL) {
+ PyObject *v = _PyDict_GetItemStringWithError(fp->dict, name);
+ if (v == NULL && PyErr_Occurred()) {
+ return NULL;
+ }
+ else if (v != NULL) {
Py_INCREF(v);
return v;
}