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':
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'

@ -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):

@ -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)

@ -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)

Loading…
Cancel
Save