Skip to content

Commit bfa4ad3

Browse files
committedJul 18, 2016
MAINT: Fix remaining uses of deprecated Python imp module.
1 parent 055056a commit bfa4ad3

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed
 

‎numpy/core/setup.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
from numpy.distutils import log
1111
from distutils.dep_util import newer
1212
from distutils.sysconfig import get_config_var
13-
from numpy._build_utils.apple_accelerate import (uses_accelerate_framework,
14-
get_sgemv_fix)
15-
13+
from numpy._build_utils.apple_accelerate import (
14+
uses_accelerate_framework, get_sgemv_fix
15+
)
16+
from numpy.compat import npy_load_module
1617
from setup_common import *
1718

1819
# Set to True to enable relaxed strides checking. This (mostly) means
@@ -386,9 +387,8 @@ def configuration(parent_package='',top_path=None):
386387

387388
generate_umath_py = join(codegen_dir, 'generate_umath.py')
388389
n = dot_join(config.name, 'generate_umath')
389-
generate_umath = imp.load_module('_'.join(n.split('.')),
390-
open(generate_umath_py, 'U'), generate_umath_py,
391-
('.py', 'U', 1))
390+
generate_umath = npy_load_module('_'.join(n.split('.')),
391+
generate_umath_py, ('.py', 'U', 1))
392392

393393
header_dir = 'include/numpy' # this is relative to config.path_in_package
394394

‎runtests.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,17 @@ def main(argv):
148148
if args.python:
149149
# Debugging issues with warnings is much easier if you can see them
150150
print("Enabling display of all warnings")
151-
import warnings; warnings.filterwarnings("always")
151+
import warnings
152+
import types
153+
154+
warnings.filterwarnings("always")
152155
if extra_argv:
153156
# Don't use subprocess, since we don't want to include the
154157
# current path in PYTHONPATH.
155158
sys.argv = extra_argv
156159
with open(extra_argv[0], 'r') as f:
157160
script = f.read()
158-
sys.modules['__main__'] = imp.new_module('__main__')
161+
sys.modules['__main__'] = types.ModuleType('__main__')
159162
ns = dict(__name__='__main__',
160163
__file__=extra_argv[0])
161164
exec_(script, ns)

0 commit comments

Comments
 (0)