diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2014-01-02 16:27:28 -0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2014-01-02 16:27:28 -0800 |
commit | b8b58bcec749edb01f49daf1ec37d9e9f8422dbb (patch) | |
tree | c233c6ff381917606c085ed900e4de1f532177d7 | |
parent | b91d3f456040a39a37cc1281ba499cb4316d15ec (diff) | |
parent | 9dbeb2ef07c0afadbe368a7e73baa428b3760816 (diff) | |
download | numpy-b8b58bcec749edb01f49daf1ec37d9e9f8422dbb.tar.gz |
Merge pull request #4158 from rgommers/f2py-no-reload
MAINT: remove use of ``reload`` from f2py. See gh-4139.
-rwxr-xr-x | numpy/f2py/crackfortran.py | 45 | ||||
-rwxr-xr-x | numpy/f2py/f2py2e.py | 6 |
2 files changed, 41 insertions, 10 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index d0d8aa8fa..893081126 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -166,12 +166,8 @@ skipemptyends=0 # for old F77 programs without 'program' statement ignorecontains=1 dolowercase=1 debug=[] -## do_analyze = 1 - -###### global variables - -## use reload(crackfortran) to reset these variables +# Global variables groupcounter=0 grouplist={groupcounter:[]} neededmodule=-1 @@ -188,6 +184,45 @@ onlyfuncs=[] include_paths=[] previous_context = None + +def reset_global_f2py_vars(): + global groupcounter, grouplist, neededmodule, expectbegin, \ + skipblocksuntil, usermodules, f90modulevars, gotnextfile, \ + filepositiontext, currentfilename, skipfunctions, skipfuncs, \ + onlyfuncs, include_paths, previous_context, \ + strictf77, sourcecodeform, quiet, verbose, tabchar, pyffilename, \ + f77modulename, skipemptyends, ignorecontains, dolowercase, debug + + # flags + strictf77 = 1 + sourcecodeform = 'fix' + quiet = 0 + verbose = 1 + tabchar = 4*' ' + pyffilename = '' + f77modulename = '' + skipemptyends = 0 + ignorecontains = 1 + dolowercase = 1 + debug = [] + # variables + groupcounter = 0 + grouplist = {groupcounter:[]} + neededmodule =-1 + expectbegin = 1 + skipblocksuntil = -1 + usermodules = [] + f90modulevars = {} + gotnextfile = 1 + filepositiontext = '' + currentfilename = '' + skipfunctions = [] + skipfuncs = [] + onlyfuncs = [] + include_paths = [] + previous_context = None + + ###### Some helper functions def show(o,f=0):pprint.pprint(o) errmess=sys.stderr.write diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 011b430d5..ff9d19e9d 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -348,11 +348,7 @@ def run_main(comline_list): """Run f2py as if string.join(comline_list,' ') is used as a command line. In case of using -h flag, return None. """ - if sys.version_info[0] >= 3: - import imp - imp.reload(crackfortran) - else: - reload(crackfortran) + crackfortran.reset_global_f2py_vars() f2pydir=os.path.dirname(os.path.abspath(cfuncs.__file__)) fobjhsrc = os.path.join(f2pydir, 'src', 'fortranobject.h') fobjcsrc = os.path.join(f2pydir, 'src', 'fortranobject.c') |