[28635] in Source-Commits
build-system commit: Clean up bare excepts and thwarted reraises
daemon@ATHENA.MIT.EDU (Anders Kaseorg)
Tue Jun 21 04:07:02 2016
Date: Tue, 21 Jun 2016 04:06:58 -0400
From: Anders Kaseorg <andersk@mit.edu>
Message-Id: <201606210806.u5L86wvx031106@drugstore.mit.edu>
To: source-commits@mit.edu
https://github.com/mit-athena/build-system/commit/0d967e0a03dd5a3c915be9926505ef54b400ed8d
commit 0d967e0a03dd5a3c915be9926505ef54b400ed8d
Author: Debathena Build System <debathena@mit.edu>
Date: Tue Jun 21 03:33:14 2016 -0400
Clean up bare excepts and thwarted reraises
athena-upstream-tarball | 8 ++++----
dabuild | 4 ++--
dabuildsys/apt.py | 10 +++++-----
dabuildsys/checkout.py | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/athena-upstream-tarball b/athena-upstream-tarball
index d2e5f00..bcf1a4e 100755
--- a/athena-upstream-tarball
+++ b/athena-upstream-tarball
@@ -28,7 +28,7 @@ def get_version_by_autoconf(rev):
try:
text = rev.read_file("configure.ac")
- except:
+ except subprocess.CalledProcessError:
return None
lines = text.split("\n")
@@ -50,7 +50,7 @@ def get_version_by_python_distutils(rev):
try:
text = rev.read_file("setup.py")
- except:
+ except subprocess.CalledProcessError:
return None
root = rev.repo.root
@@ -118,14 +118,14 @@ def build_upstream_tarball(package, do_build = True, do_pristine_tar = False, al
else:
try:
version = latest.read_file("VERSION")
- except:
+ except subprocess.CalledProcessError:
raise BuildError("No VERSION file found, and no other way to determine current version was provided")
method = 'git archive'
# The tag must exist in order for build to succeed
try:
tagged = repo.read_tag(version)
- except:
+ except subprocess.CalledProcessError:
raise BuildError("Unable to find the tag corresponding to version %s" % version)
# Determine the relevant filenames and paths
diff --git a/dabuild b/dabuild
index 35a46d9..00eb478 100755
--- a/dabuild
+++ b/dabuild
@@ -22,7 +22,7 @@ def build_package(distro, release, package, arch):
try:
dsc_path, = [f.path for f in package.files if f.name.endswith('.dsc')]
- except:
+ except ValueError:
raise BuildError("Source package %s has more than one dsc file" % package.name)
tag = '~' + dabuildsys.release_tags[release]
@@ -316,7 +316,7 @@ if __name__ == '__main__':
main()
except subprocess.CalledProcessError as err:
print err.output
- raise err
+ raise
finally:
dabuildsys.release_lock()
diff --git a/dabuildsys/apt.py b/dabuildsys/apt.py
index ba71c38..9f57bd8 100644
--- a/dabuildsys/apt.py
+++ b/dabuildsys/apt.py
@@ -68,7 +68,7 @@ class APTSourcePackage(object):
try:
tarpath, = [f.path for f in self.files if f.name.startswith(tarname)]
- except:
+ except ValueError:
raise BuildError("File %s.{gz,bz2,xz} not found for package %s" % (tarname, self.name))
with tarfile.open(tarpath, 'r:*') as tar:
@@ -81,7 +81,7 @@ class APTSourcePackage(object):
if len(self.files) == 2:
try:
tarpath, = [f.path for f in self.files if f.name.endswith('.tar.gz')]
- except:
+ except ValueError:
raise BuildError("Package %s has format 1.0 and does not seem to have the tarball" % self.name)
with tarfile.open(tarpath, 'r:*') as tar:
@@ -91,7 +91,7 @@ class APTSourcePackage(object):
diffname = "%s_%s.diff.gz" % (self.name, str(self.version))
try:
diffpath, = [f.path for f in self.files if f.name == diffname]
- except:
+ except ValueError:
raise BuildError("File %s not found for package %s" % (diffname, self.name))
diff = gzip.open(diffpath, 'r')
@@ -140,7 +140,7 @@ class APTSourcePackage(object):
# Cache those which still do
try:
return self.cached_architectures
- except:
+ except AttributeError:
pass
control = self.get_control_file()
@@ -303,7 +303,7 @@ def compare_against_git(apt_repo, update_all=False, checkout_cache=None):
checkout = checkout_cache[package]
if not checkout:
continue
- except:
+ except KeyError:
checkout = PackageCheckout(package, full_clean=update_all)
if use_cache:
checkout_cache[package] = checkout
diff --git a/dabuildsys/checkout.py b/dabuildsys/checkout.py
index 7c50ff8..236ddbb 100644
--- a/dabuildsys/checkout.py
+++ b/dabuildsys/checkout.py
@@ -59,7 +59,7 @@ class PackageCheckout(git.GitRepository):
def validate_native(self):
try:
source_format = self.get_debian_file('source/format')
- except:
+ except subprocess.CalledProcessError:
raise BuildError('Package does not specify the source format')
if source_format != '3.0 (native)':