diff options
author | Matti Picus <matti.picus@gmail.com> | 2019-12-05 13:26:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 13:26:44 +0200 |
commit | 1783e6fc437f34af1d652cbae36a68abcbf41fbc (patch) | |
tree | 4bce264cfcafca39df9fe41fa96d6a009017523e /numpy/f2py/rules.py | |
parent | 9a79803e5edd0819bfa4c19a3442f75209fee5ec (diff) | |
parent | 3c6bbd7b43bf584aeef780a9e42acf2ecce7b179 (diff) | |
download | numpy-1783e6fc437f34af1d652cbae36a68abcbf41fbc.tar.gz |
Merge pull request #15022 from eric-wieser/better-f2py-error
ENH: f2py: improve error messages
Diffstat (limited to 'numpy/f2py/rules.py')
-rwxr-xr-x | numpy/f2py/rules.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index f2f713bde..28eb9da30 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -1064,8 +1064,10 @@ if (#varname#_capi==Py_None) { '\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,#varname#_capi);'}, """\ \tif (capi_#varname#_tmp == NULL) { -\t\tif (!PyErr_Occurred()) -\t\t\tPyErr_SetString(#modulename#_error,\"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array\" ); +\t\tPyObject *exc, *val, *tb; +\t\tPyErr_Fetch(&exc, &val, &tb); +\t\tPyErr_SetString(exc ? exc : #modulename#_error,\"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array\" ); +\t\tnpy_PyErr_ChainExceptionsCause(exc, val, tb); \t} else { \t\t#varname# = (#ctype# *)(PyArray_DATA(capi_#varname#_tmp)); """, @@ -1081,8 +1083,10 @@ if (#varname#_capi==Py_None) { \t\t\twhile ((_i = nextforcomb())) \t\t\t\t#varname#[capi_i++] = #init#; /* fortran way */ \t\t} else { -\t\t\tif (!PyErr_Occurred()) -\t\t\t\tPyErr_SetString(#modulename#_error,\"Initialization of #nth# #varname# failed (initforcomb).\"); +\t\t\tPyObject *exc, *val, *tb; +\t\t\tPyErr_Fetch(&exc, &val, &tb); +\t\t\tPyErr_SetString(exc ? exc : #modulename#_error,\"Initialization of #nth# #varname# failed (initforcomb).\"); +\t\t\tnpy_PyErr_ChainExceptionsCause(exc, val, tb); \t\t\tf2py_success = 0; \t\t} \t} |