summaryrefslogtreecommitdiff
path: root/numpy/f2py
diff options
context:
space:
mode:
authorjutke <jutke@allstate.com>2017-01-17 12:33:34 -0600
committerjutke <jutke@allstate.com>2017-01-20 09:31:03 -0600
commit892c54cda15163552fa2245b476aa765f2aa2061 (patch)
tree3c9e935e69e8956e49ffce2cc1587e4304b2c994 /numpy/f2py
parent6f378b36f16d1667704234a2f6287588a04e210b (diff)
downloadnumpy-892c54cda15163552fa2245b476aa765f2aa2061.tar.gz
BUG: guard against replacing constants without '_' spec
fixes #8493 In the reported problem snippet the attempt to infer the type of parameter (wasize=maxiterates*2) leads to a lookup of maxiterates in the logic of get_parameters which finds and correctly assigns to 'v' the value string '50000' However, then in the logic proceds to attempt to split off any underscore-appended precision spec from v_ which yields ['50000'] because there is no underscore. Finally line v = ''.join(v_[:-1]).lower().replace(v_[-1].lower(), '') if not quarded by the newly introduced lengthtest sets v to empty because [:-1] of a list with one element yields an empty list. Subsequently the type inference by running eval on an empty string fails with the error message quoted. The introduced length check appears to correct this problem.
Diffstat (limited to 'numpy/f2py')
-rwxr-xr-xnumpy/f2py/crackfortran.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py
index 2bdb21bb3..ce583c7b2 100755
--- a/numpy/f2py/crackfortran.py
+++ b/numpy/f2py/crackfortran.py
@@ -2451,7 +2451,8 @@ def get_parameters(vars, global_params={}):
if not selected_kind_re.match(v):
v_ = v.split('_')
# In case there are additive parameters
- v = ''.join(v_[:-1]).lower().replace(v_[-1].lower(), '')
+ if len(v_)>1:
+ v = ''.join(v_[:-1]).lower().replace(v_[-1].lower(), '')
# Currently this will not work for complex numbers.
# There is missing code for extracting a complex number,