diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-01-05 21:16:11 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-01-05 21:22:53 +0000 |
commit | da0497fdf35a7bf851f3625b0df07cde950f5f49 (patch) | |
tree | 2bfd303e0c20edbbc2b0523b852f6f9710e4dd92 /numpy/distutils/fcompiler | |
parent | 6253ff78be7f21898178799758717bfe59368b94 (diff) | |
download | numpy-da0497fdf35a7bf851f3625b0df07cde950f5f49.tar.gz |
MAINT: cleanup use of sys.exc_info
This code originates from python 2.6, before there was an `as` clause in `except`.
This removes all callers of `numpy.distutils.compat.get_exception`.
Diffstat (limited to 'numpy/distutils/fcompiler')
-rw-r--r-- | numpy/distutils/fcompiler/__init__.py | 12 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/compaq.py | 10 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/gnu.py | 5 |
3 files changed, 10 insertions, 17 deletions
diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 3723470f3..81a3b96c9 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -36,7 +36,6 @@ from numpy.distutils import log from numpy.distutils.misc_util import is_string, all_strings, is_sequence, \ make_temp_file, get_shared_lib_extension from numpy.distutils.exec_command import find_executable -from numpy.distutils.compat import get_exception from numpy.distutils import _shell_utils from .environment import EnvironmentConfig @@ -614,8 +613,8 @@ class FCompiler(CCompiler): src) try: self.spawn(command, display=display) - except DistutilsExecError: - msg = str(get_exception()) + except DistutilsExecError as e: + msg = str(e) raise CompileError(msg) def module_options(self, module_dirs, module_build_dir): @@ -682,8 +681,8 @@ class FCompiler(CCompiler): command = linker + ld_args try: self.spawn(command) - except DistutilsExecError: - msg = str(get_exception()) + except DistutilsExecError as e: + msg = str(e) raise LinkError(msg) else: log.debug("skipping %s (up-to-date)", output_filename) @@ -931,8 +930,7 @@ def show_fcompilers(dist=None): c = new_fcompiler(compiler=compiler, verbose=dist.verbose) c.customize(dist) v = c.get_version() - except (DistutilsModuleError, CompilerNotFound): - e = get_exception() + except (DistutilsModuleError, CompilerNotFound) as e: log.debug("show_fcompilers: %s not found" % (compiler,)) log.debug(repr(e)) diff --git a/numpy/distutils/fcompiler/compaq.py b/numpy/distutils/fcompiler/compaq.py index 671b3a55f..51ad20d01 100644 --- a/numpy/distutils/fcompiler/compaq.py +++ b/numpy/distutils/fcompiler/compaq.py @@ -6,7 +6,6 @@ import os import sys from numpy.distutils.fcompiler import FCompiler -from numpy.distutils.compat import get_exception from distutils.errors import DistutilsPlatformError compilers = ['CompaqFCompiler'] @@ -82,19 +81,16 @@ class CompaqVisualFCompiler(FCompiler): ar_exe = m.lib except DistutilsPlatformError: pass - except AttributeError: - msg = get_exception() + except AttributeError as e: if '_MSVCCompiler__root' in str(msg): print('Ignoring "%s" (I think it is msvccompiler.py bug)' % (msg)) else: raise - except IOError: - e = get_exception() + except IOError as e: if not "vcvarsall.bat" in str(e): print("Unexpected IOError in", __file__) raise e - except ValueError: - e = get_exception() + except ValueError as e: if not "'path'" in str(e): print("Unexpected ValueError in", __file__) raise e diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 965c67041..1c71dd2bd 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -12,7 +12,6 @@ import subprocess from subprocess import Popen, PIPE, STDOUT from numpy.distutils.exec_command import filepath_from_subprocess_output from numpy.distutils.fcompiler import FCompiler -from numpy.distutils.compat import get_exception from numpy.distutils.system_info import system_info compilers = ['GnuFCompiler', 'Gnu95FCompiler'] @@ -560,5 +559,5 @@ if __name__ == '__main__': print(customized_fcompiler('gnu').get_version()) try: print(customized_fcompiler('g95').get_version()) - except Exception: - print(get_exception()) + except Exception as e: + print(e) |