summaryrefslogtreecommitdiff
path: root/numpy/distutils
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/distutils')
-rw-r--r--numpy/distutils/fcompiler/gnu.py1
-rw-r--r--numpy/distutils/system_info.py11
-rw-r--r--numpy/distutils/tests/test_system_info.py4
3 files changed, 10 insertions, 6 deletions
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py
index 7c3dc4162..9697aa8db 100644
--- a/numpy/distutils/fcompiler/gnu.py
+++ b/numpy/distutils/fcompiler/gnu.py
@@ -364,6 +364,7 @@ def _can_target(cmd, arch):
"""Return true if the architecture supports the -arch flag"""
newcmd = cmd[:]
fid, filename = tempfile.mkstemp(suffix=".f")
+ fid.close()
try:
d = os.path.dirname(filename)
output = os.path.splitext(filename)[0] + ".o"
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 014223b74..c3a62464b 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -242,7 +242,7 @@ else:
# tests are run in debug mode Python 3.
tmp = open(os.devnull, 'w')
p = sp.Popen(["gcc", "-print-multiarch"], stdout=sp.PIPE,
- stderr=tmp)
+ stderr=tmp)
except (OSError, DistutilsError):
# OSError if gcc is not installed, or SandboxViolation (DistutilsError
# subclass) if an old setuptools bug is triggered (see gh-3160).
@@ -971,10 +971,11 @@ class mkl_info(system_info):
paths = os.environ.get('LD_LIBRARY_PATH', '').split(os.pathsep)
ld_so_conf = '/etc/ld.so.conf'
if os.path.isfile(ld_so_conf):
- for d in open(ld_so_conf, 'r'):
- d = d.strip()
- if d:
- paths.append(d)
+ with open(ld_so_conf, 'r') as f:
+ for d in f:
+ d = d.strip()
+ if d:
+ paths.append(d)
intel_mkl_dirs = []
for path in paths:
path_atoms = path.split(os.sep)
diff --git a/numpy/distutils/tests/test_system_info.py b/numpy/distutils/tests/test_system_info.py
index 0f45cd79e..54975cae5 100644
--- a/numpy/distutils/tests/test_system_info.py
+++ b/numpy/distutils/tests/test_system_info.py
@@ -69,7 +69,9 @@ def have_compiler():
return False
cmd = [compiler.cc]
try:
- Popen(cmd, stdout=PIPE, stderr=PIPE)
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ p.stdout.close()
+ p.stderr.close()
except OSError:
return False
return True