diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-01-05 21:43:01 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-01-11 19:57:12 +0000 |
commit | c8bdb9c7f91d12f20a3c6a27d776e2bc4a916d81 (patch) | |
tree | 963345e397c00ef098cf73abc3c6c7c8b3f6fda6 /numpy/f2py/crackfortran.py | |
parent | c9fd0e7c1e077d3044b4f2cd419b89c8bf0544c7 (diff) | |
download | numpy-c8bdb9c7f91d12f20a3c6a27d776e2bc4a916d81.tar.gz |
MAINT: Eliminate some calls to `eval`
* The instance in `_internal` is parsing tuples and integers, so `ast.literal_eval` is just fine
* The instance in `crack_fortran` is just trying to lookup a function name dynamically
* The instance in `f90mod_rules` is looking at the result of `capi_maps.getarrdims(...)['rank']`, which is always a string representation of an integer
The f2py code is still littered with `eval`, but the remaining cases were harder to reason about.
Diffstat (limited to 'numpy/f2py/crackfortran.py')
-rwxr-xr-x | numpy/f2py/crackfortran.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 910120e00..31e01242e 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -3113,11 +3113,12 @@ def true_intent_list(var): ret = [] for intent in lst: try: - c = eval('isintent_%s(var)' % intent) - except NameError: - c = 0 - if c: - ret.append(intent) + f = globals()['isintent_%s' % intent] + except KeyError: + c = False + else: + if f(var): + ret.append(intent) return ret |