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.
pull/3205/head
Aleksey Filippov 7 years ago
parent d977b78f1b
commit e4faf396e6
  1. 4
      mesonbuild/compilers/c.py
  2. 2
      mesonbuild/coredata.py
  3. 2
      mesonbuild/scripts/meson_install.py
  4. 4
      test cases/common/72 build always/version_gen.py

@ -525,7 +525,7 @@ class CCompiler(Compiler):
elif rtype == 'int': elif rtype == 'int':
try: try:
return int(res.stdout.strip()) return int(res.stdout.strip())
except: except ValueError:
m = 'Return value of {}() is not an int' m = 'Return value of {}() is not an int'
raise EnvironmentException(m.format(fname)) raise EnvironmentException(m.format(fname))
@ -1140,7 +1140,7 @@ class VisualStudioCCompiler(CCompiler):
# See boost/config/compiler/visualc.cpp for up to date mapping # See boost/config/compiler/visualc.cpp for up to date mapping
try: try:
version = int(''.join(self.version.split('.')[0:2])) version = int(''.join(self.version.split('.')[0:2]))
except: except ValueError:
return None return None
if version < 1310: if version < 1310:
return '7.0' return '7.0'

@ -111,7 +111,7 @@ class UserIntegerOption(UserOption):
def toint(self, valuestring): def toint(self, valuestring):
try: try:
return int(valuestring) return int(valuestring)
except: except ValueError:
raise MesonException('Value string "%s" is not convertable to an integer.' % valuestring) raise MesonException('Value string "%s" is not convertable to an integer.' % valuestring)
def validate_value(self, value): def validate_value(self, value):

@ -283,7 +283,7 @@ def run_install_script(d):
rc = subprocess.call(script + args, env=child_env) rc = subprocess.call(script + args, env=child_env)
if rc != 0: if rc != 0:
sys.exit(rc) sys.exit(rc)
except: except Exception:
print('Failed to run install script {!r}'.format(name)) print('Failed to run install script {!r}'.format(name))
sys.exit(1) sys.exit(1)

@ -12,7 +12,7 @@ def generate(infile, outfile, fallback):
(stdo, _) = p.communicate() (stdo, _) = p.communicate()
if p.returncode == 0: if p.returncode == 0:
version = stdo.decode().strip() version = stdo.decode().strip()
except: except Exception:
pass pass
with open(infile) as f: with open(infile) as f:
newdata = f.read().replace('@VERSION@', version) newdata = f.read().replace('@VERSION@', version)
@ -21,7 +21,7 @@ def generate(infile, outfile, fallback):
olddata = f.read() olddata = f.read()
if olddata == newdata: if olddata == newdata:
return return
except: except Exception:
pass pass
with open(outfile, 'w') as f: with open(outfile, 'w') as f:
f.write(newdata) f.write(newdata)

Loading…
Cancel
Save