diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2019-08-08 14:33:03 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2019-08-19 13:13:36 -0500 |
commit | c091779f63521e13d9f7af4ff113dde8cc5f6a7f (patch) | |
tree | ce1e29da778995b4467064d278a6a58a946e11ee /numpy/f2py/tests/util.py | |
parent | 684bee2ae868c1bd8cb4fd4066d447ca35bd848e (diff) | |
download | numpy-c091779f63521e13d9f7af4ff113dde8cc5f6a7f.tar.gz |
BUG: Further, followup f2py reference count fixes
Note that the extension module dict seems to be never dereferenced
(there is an additional reference to it kept around somewhere).
This reference seems to part of the C python module loading
(possibly intentionally), and I could not find how to remove it or
where it originates from.
Diffstat (limited to 'numpy/f2py/tests/util.py')
-rw-r--r-- | numpy/f2py/tests/util.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index d20dc5908..77cb612d0 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -31,6 +31,7 @@ except ImportError: # _module_dir = None +_module_num = 5403 def _cleanup(): @@ -59,13 +60,14 @@ def get_module_dir(): def get_temp_module_name(): # Assume single-threaded, and the module dir usable only by this thread + global _module_num d = get_module_dir() - for j in range(5403, 9999999): - name = "_test_ext_module_%d" % j - fn = os.path.join(d, name) - if name not in sys.modules and not os.path.isfile(fn + '.py'): - return name - raise RuntimeError("Failed to create a temporary module name") + name = "_test_ext_module_%d" % _module_num + _module_num += 1 + if name in sys.modules: + # this should not be possible, but check anyway + raise RuntimeError("Temporary module name already in use.") + return name def _memoize(func): |