diff options
author | Aleksey Filippov <alekseyf@google.com> | 2018-03-09 01:20:26 +0000 |
---|---|---|
committer | Aleksey Filippov <alekseyf@google.com> | 2018-03-11 23:36:04 +0000 |
commit | e4faf396e62813665e44fc742e7f355ad532f4d2 (patch) | |
tree | 8976409cd8eb35d862270d0cc90217b96109af6e | |
parent | d977b78f1b6f95a6eab3da8a6d7d9ad06d8b80fd (diff) | |
download | meson-e4faf396e62813665e44fc742e7f355ad532f4d2.zip meson-e4faf396e62813665e44fc742e7f355ad532f4d2.tar.gz meson-e4faf396e62813665e44fc742e7f355ad532f4d2.tar.bz2 |
Do not use bare except [flake8]
Use more specific exception types where appropriate.
This patch does not change bare except calls if exception is re-raised.
-rw-r--r-- | mesonbuild/compilers/c.py | 4 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 2 | ||||
-rw-r--r-- | mesonbuild/scripts/meson_install.py | 2 | ||||
-rwxr-xr-x | test cases/common/72 build always/version_gen.py | 4 |
4 files changed, 6 insertions, 6 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 1c9b9b4..2d14116 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -525,7 +525,7 @@ class CCompiler(Compiler): elif rtype == 'int': try: return int(res.stdout.strip()) - except: + except ValueError: m = 'Return value of {}() is not an int' raise EnvironmentException(m.format(fname)) @@ -1140,7 +1140,7 @@ class VisualStudioCCompiler(CCompiler): # See boost/config/compiler/visualc.cpp for up to date mapping try: version = int(''.join(self.version.split('.')[0:2])) - except: + except ValueError: return None if version < 1310: return '7.0' diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index e2a0b48..993effc 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -111,7 +111,7 @@ class UserIntegerOption(UserOption): def toint(self, valuestring): try: return int(valuestring) - except: + except ValueError: raise MesonException('Value string "%s" is not convertable to an integer.' % valuestring) def validate_value(self, value): diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py index cbc782d..2a23f81 100644 --- a/mesonbuild/scripts/meson_install.py +++ b/mesonbuild/scripts/meson_install.py @@ -283,7 +283,7 @@ def run_install_script(d): rc = subprocess.call(script + args, env=child_env) if rc != 0: sys.exit(rc) - except: + except Exception: print('Failed to run install script {!r}'.format(name)) sys.exit(1) diff --git a/test cases/common/72 build always/version_gen.py b/test cases/common/72 build always/version_gen.py index d7b01ca..e5a0c2c 100755 --- a/test cases/common/72 build always/version_gen.py +++ b/test cases/common/72 build always/version_gen.py @@ -12,7 +12,7 @@ def generate(infile, outfile, fallback): (stdo, _) = p.communicate() if p.returncode == 0: version = stdo.decode().strip() - except: + except Exception: pass with open(infile) as f: newdata = f.read().replace('@VERSION@', version) @@ -21,7 +21,7 @@ def generate(infile, outfile, fallback): olddata = f.read() if olddata == newdata: return - except: + except Exception: pass with open(outfile, 'w') as f: f.write(newdata) |