diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-01-06 18:57:47 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-01-14 15:06:52 +0000 |
commit | e2921434a07c22714bbf242be5389c3056449863 (patch) | |
tree | d0272d304ff0cde77a1953d4ec46d82a8b0af453 /numpy/f2py/src/fortranobject.c | |
parent | fbd807f5c5587407847f1aa54e6dada79bb90c35 (diff) | |
download | numpy-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.c | 7 |
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; } |