diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-03-03 12:40:59 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-03-03 18:08:08 -0700 |
commit | 96ea318b10e31c405798a3f96d93b418d188969d (patch) | |
tree | ad460a1ede966a155ea8656d956422818354a68d /numpy/distutils/system_info.py | |
parent | e24e0d8d41cf2b64bc4e34ee71618c10c9043e5f (diff) | |
download | numpy-96ea318b10e31c405798a3f96d93b418d188969d.tar.gz |
MAINT: Get rid of a ResourceWarning.
This one in numpy/distutils/system_info.py. Just keep an explicit
reference to a file, then close it.
Diffstat (limited to 'numpy/distutils/system_info.py')
-rw-r--r-- | numpy/distutils/system_info.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 68a9ba5a9..1f3ce2ddb 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -218,8 +218,11 @@ else: import subprocess as sp try: + # Explicitly open/close file to avoid ResourceWarning when + # tests are run in debug mode Python 3. + tmp = open(os.devnull, 'w') p = sp.Popen(["gcc", "-print-multiarch"], stdout=sp.PIPE, - stderr=open(os.devnull, 'w')) + stderr=tmp) except OSError: pass # gcc is not installed else: @@ -228,6 +231,8 @@ else: # gcc supports the "-print-multiarch" option default_x11_lib_dirs += [os.path.join("/usr/lib/", triplet)] default_lib_dirs += [os.path.join("/usr/lib/", triplet)] + finally: + tmp.close() if os.path.join(sys.prefix, 'lib') not in default_lib_dirs: default_lib_dirs.insert(0, os.path.join(sys.prefix, 'lib')) |