diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2021-01-19 11:00:28 +0200 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2021-01-19 11:00:28 +0200 |
commit | 065f50706192d62fc00ff39660ea051539845f12 (patch) | |
tree | 9c1177f18599ad7d6ea3f22dbdc4b79d447927f1 | |
parent | 624e9b42381b81442a59f51f8c0d57c787b3366e (diff) | |
download | numpy-065f50706192d62fc00ff39660ea051539845f12.tar.gz |
Apply reviewers comments.
-rwxr-xr-x | numpy/f2py/crackfortran.py | 10 | ||||
-rw-r--r-- | numpy/f2py/tests/test_callback.py | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 2aa8dc420..1149633c0 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -3232,11 +3232,11 @@ def vars2fortran(block, vars, args, tab='', as_interface=False): outmess('vars2fortran: No definition for argument "%s".\n' % a) continue if a == block['name']: - if block['block'] == 'function': - if block.get('result'): - # skip declaring function if its result is already declared - continue - else: + if block['block'] != 'function' or block.get('result'): + # 1) skip declaring a variable that name matches with + # subroutine name + # 2) skip declaring function when its type is + # declared via `result` construction continue if 'typespec' not in vars[a]: if 'attrspec' in vars[a] and 'external' in vars[a]['attrspec']: diff --git a/numpy/f2py/tests/test_callback.py b/numpy/f2py/tests/test_callback.py index acf8c2392..6a59b6398 100644 --- a/numpy/f2py/tests/test_callback.py +++ b/numpy/f2py/tests/test_callback.py @@ -218,13 +218,13 @@ class TestF90Callback(util.F2PyTest): suffix = '.f90' code = """ -function gh17797(f, y) result(r) - external f - integer(8) :: r, f - integer(8), dimension(:) :: y - r = f(0) - r = r + sum(y) -end function gh17797 + function gh17797(f, y) result(r) + external f + integer(8) :: r, f + integer(8), dimension(:) :: y + r = f(0) + r = r + sum(y) + end function gh17797 """ def test_gh17797(self): |