launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27354
[Merge] ~twom/launchpad:lint-e722 into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:lint-e722 into launchpad:master.
Commit message:
Fix E722 violations
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/406640
Swap bare except for `except Exception`
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:lint-e722 into launchpad:master.
diff --git a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
index e2d22a6..8172bef 100644
--- a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
+++ b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
@@ -543,7 +543,7 @@ class PublishFTPMaster(LaunchpadCronScript):
# Swizzle the now-updated backup dists and the current dists
# around.
self.installDists(distribution)
- except:
+ except Exception:
# If we failed here, there's a chance that we left a
# working dists directory in its temporary location. If so,
# recover it. The next script run would do that anyway, but
diff --git a/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py b/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py
index 2039856..3861a50 100644
--- a/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py
+++ b/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py
@@ -1100,7 +1100,7 @@ class TestCreateDistroSeriesIndexes(TestCaseWithFactory, HelpersMixin):
script.runPublishDistro = FakeMethod(failure=Boom("Sorry!"))
try:
script.createIndexes(series.distribution, [get_a_suite(series)])
- except:
+ except Exception:
pass
self.assertEqual([], script.markIndexCreationComplete.calls)
diff --git a/lib/lp/archiveuploader/dscfile.py b/lib/lp/archiveuploader/dscfile.py
index 369f8d9..ba47bd3 100644
--- a/lib/lp/archiveuploader/dscfile.py
+++ b/lib/lp/archiveuploader/dscfile.py
@@ -90,7 +90,7 @@ def unpack_source(dsc_filepath):
unpacked_dir = tempfile.mkdtemp()
try:
extract_dpkg_source(dsc_filepath, unpacked_dir)
- except:
+ except Exception:
shutil.rmtree(unpacked_dir)
raise
diff --git a/lib/lp/archiveuploader/uploadprocessor.py b/lib/lp/archiveuploader/uploadprocessor.py
index b8d1148..1eb33f9 100644
--- a/lib/lp/archiveuploader/uploadprocessor.py
+++ b/lib/lp/archiveuploader/uploadprocessor.py
@@ -53,6 +53,7 @@ import sys
import scandir
from sqlobject import SQLObjectNotFound
+from storm.expr import Except
from zope.component import getUtility
from lp.app.errors import NotFoundError
@@ -432,7 +433,7 @@ class UploadHandler:
"Committing the transaction and any mails associated "
"with this upload.")
self.processor.ztm.commit()
- except:
+ except Exception:
self.processor.ztm.abort()
raise
@@ -605,7 +606,7 @@ class BuildUploadHandler(UploadHandler):
"with this upload.")
self.processor.ztm.commit()
return UploadStatusEnum.ACCEPTED
- except:
+ except Exception:
self.processor.ztm.abort()
raise
@@ -630,7 +631,7 @@ class BuildUploadHandler(UploadHandler):
except UploadError as e:
logger.error(str(e))
return UploadStatusEnum.REJECTED
- except:
+ except Exception:
self.processor.ztm.abort()
raise
@@ -681,7 +682,7 @@ class BuildUploadHandler(UploadHandler):
except UploadError as e:
logger.error(str(e))
return UploadStatusEnum.REJECTED
- except:
+ except Exception:
self.processor.ztm.abort()
raise
diff --git a/lib/lp/bugs/externalbugtracker/bugzilla.py b/lib/lp/bugs/externalbugtracker/bugzilla.py
index 7ab8ac5..830f680 100644
--- a/lib/lp/bugs/externalbugtracker/bugzilla.py
+++ b/lib/lp/bugs/externalbugtracker/bugzilla.py
@@ -517,7 +517,7 @@ class Bugzilla(ExternalBugTracker):
if bug_id not in self.remote_bug_importance:
return "Bug %s is not in remote_bug_importance" % bug_id
return self.remote_bug_importance[bug_id]
- except:
+ except Exception:
return UNKNOWN_REMOTE_IMPORTANCE
def getRemoteStatus(self, bug_id):
diff --git a/lib/lp/bugs/scripts/checkwatches/base.py b/lib/lp/bugs/scripts/checkwatches/base.py
index 016ea8e..563a035 100644
--- a/lib/lp/bugs/scripts/checkwatches/base.py
+++ b/lib/lp/bugs/scripts/checkwatches/base.py
@@ -163,7 +163,7 @@ class WorkingBase:
check_no_transaction()
try:
yield self._transaction_manager
- except:
+ except Exception:
self._transaction_manager.abort()
# Let the exception propagate.
raise
diff --git a/lib/lp/bugs/vocabularies.py b/lib/lp/bugs/vocabularies.py
index 7863a3b..5c4c70a 100644
--- a/lib/lp/bugs/vocabularies.py
+++ b/lib/lp/bugs/vocabularies.py
@@ -407,7 +407,7 @@ class BugTaskMilestoneVocabulary:
"""See `IVocabularyTokenized`."""
try:
return self.toTerm(self.milestones[str(token)])
- except:
+ except Exception:
raise LookupError(token)
def __len__(self):
diff --git a/lib/lp/code/model/directbranchcommit.py b/lib/lp/code/model/directbranchcommit.py
index 89586b0..4569595 100644
--- a/lib/lp/code/model/directbranchcommit.py
+++ b/lib/lp/code/model/directbranchcommit.py
@@ -118,7 +118,7 @@ class DirectBranchCommit:
db_branch, get_branch_info(self.bzrbranch))
self.is_open = True
- except:
+ except Exception:
self.unlock()
raise
diff --git a/lib/lp/code/model/sourcepackagerecipebuild.py b/lib/lp/code/model/sourcepackagerecipebuild.py
index 0320c77..aac5a0f 100644
--- a/lib/lp/code/model/sourcepackagerecipebuild.py
+++ b/lib/lp/code/model/sourcepackagerecipebuild.py
@@ -257,7 +257,7 @@ class SourcePackageRecipeBuild(SpecificBuildFarmJobSourceMixin,
' - cannot build against %s.' % series_name)
except ProgrammingError:
raise
- except:
+ except Exception:
logger.exception(' - problem with %s', series_name)
else:
logger.debug(' - build requested for %s', series_name)
diff --git a/lib/lp/codehosting/puller/scheduler.py b/lib/lp/codehosting/puller/scheduler.py
index e0b8363..90442cb 100644
--- a/lib/lp/codehosting/puller/scheduler.py
+++ b/lib/lp/codehosting/puller/scheduler.py
@@ -151,7 +151,7 @@ class PullerWireProtocol(NetstringReceiver):
try:
try:
method(*self._current_args)
- except:
+ except Exception:
self.puller_protocol.unexpectedError(failure.Failure())
finally:
self._resetState()
diff --git a/lib/lp/codehosting/puller/tests/__init__.py b/lib/lp/codehosting/puller/tests/__init__.py
index 350eda7..2d5b0ae 100644
--- a/lib/lp/codehosting/puller/tests/__init__.py
+++ b/lib/lp/codehosting/puller/tests/__init__.py
@@ -74,7 +74,7 @@ def fixed_handle_request(self):
if self.verify_request(request, client_address):
try:
self.process_request(request, client_address)
- except:
+ except Exception:
self.handle_error(request, client_address)
self.close_request(request)
diff --git a/lib/lp/codehosting/upgrade.py b/lib/lp/codehosting/upgrade.py
index 2159871..54112b2 100755
--- a/lib/lp/codehosting/upgrade.py
+++ b/lib/lp/codehosting/upgrade.py
@@ -174,7 +174,7 @@ class Upgrader:
bzrdir = BzrDir.create(upgrade_dir, self.get_target_format())
repository = bzrdir.create_repository()
repository.fetch(self.bzr_branch.repository)
- except:
+ except Exception:
rmtree(upgrade_dir)
raise
else:
diff --git a/lib/lp/services/database/__init__.py b/lib/lp/services/database/__init__.py
index 5af379f..2612c42 100644
--- a/lib/lp/services/database/__init__.py
+++ b/lib/lp/services/database/__init__.py
@@ -77,7 +77,7 @@ def write_transaction(func):
transaction.begin()
try:
ret = func(*args, **kwargs)
- except:
+ except Exception:
transaction.abort()
raise
transaction.commit()
diff --git a/lib/lp/services/database/sqlbase.py b/lib/lp/services/database/sqlbase.py
index cf7d5d5..8bc8f5f 100644
--- a/lib/lp/services/database/sqlbase.py
+++ b/lib/lp/services/database/sqlbase.py
@@ -42,6 +42,7 @@ from sqlobject.sqlbuilder import sqlrepr
import storm
from storm.databases.postgres import compile as postgres_compile
from storm.expr import (
+ Except,
compile as storm_compile,
State,
)
@@ -205,7 +206,7 @@ class SQLBase(storm.sqlobject.SQLObjectBase):
store.add(self)
try:
self._create(None, **kwargs)
- except:
+ except Exception:
store.remove(self)
raise
diff --git a/lib/lp/services/job/runner.py b/lib/lp/services/job/runner.py
index 2ec4506..db23f70 100644
--- a/lib/lp/services/job/runner.py
+++ b/lib/lp/services/job/runner.py
@@ -677,9 +677,9 @@ class TwistedJobRunner(BaseJobRunner):
if job is None:
self.logger.info('No jobs to run.')
self.terminated()
- except:
+ except Exception:
self.failed(failure.Failure())
- except:
+ except Exception:
self.terminated()
raise
diff --git a/lib/lp/services/job/tests/test_celeryjob.py b/lib/lp/services/job/tests/test_celeryjob.py
index 22ec50e..9757d36 100644
--- a/lib/lp/services/job/tests/test_celeryjob.py
+++ b/lib/lp/services/job/tests/test_celeryjob.py
@@ -86,7 +86,7 @@ class TestRunMissingJobs(TestCaseWithFactory):
missing_ready = find_missing_ready_obj.find_missing_ready()
try:
self.assertEqual([], missing_ready)
- except:
+ except Exception:
# XXX AaronBentley: 2012-08-01 bug=1031018: Extra diagnostic info
# to help diagnose this hard-to-reproduce failure.
self.addTextDetail('queued_job_ids',
diff --git a/lib/lp/services/librarianserver/libraryprotocol.py b/lib/lp/services/librarianserver/libraryprotocol.py
index c59ca28..bd11e39 100644
--- a/lib/lp/services/librarianserver/libraryprotocol.py
+++ b/lib/lp/services/librarianserver/libraryprotocol.py
@@ -74,7 +74,7 @@ class FileUploadProtocol(basic.LineReceiver):
getattr(self, 'line_' + self.state, self.badLine)(line)
except ProtocolViolation as e:
self.sendError(e.msg)
- except:
+ except Exception:
self.unknownError()
def sendError(self, msg, code='400'):
diff --git a/lib/lp/services/librarianserver/storage.py b/lib/lp/services/librarianserver/storage.py
index 053f37d..cebcd59 100644
--- a/lib/lp/services/librarianserver/storage.py
+++ b/lib/lp/services/librarianserver/storage.py
@@ -271,7 +271,7 @@ class LibraryFileUpload(object):
aliasID = None
self.debugLog.append('received contentID: %r' % (contentID, ))
- except:
+ except Exception:
# Abort transaction and re-raise
self.debugLog.append('failed to get contentID/aliasID, aborting')
raise
@@ -279,7 +279,7 @@ class LibraryFileUpload(object):
# Move file to final location
try:
self._move(contentID)
- except:
+ except Exception:
# Abort DB transaction
self.debugLog.append('failed to move file, aborting')
diff --git a/lib/lp/services/librarianserver/testing/tests/test_server_fixture.py b/lib/lp/services/librarianserver/testing/tests/test_server_fixture.py
index c315ca4..c960098 100644
--- a/lib/lp/services/librarianserver/testing/tests/test_server_fixture.py
+++ b/lib/lp/services/librarianserver/testing/tests/test_server_fixture.py
@@ -83,7 +83,7 @@ class TestLibrarianServerFixture(TestCase):
fixture.restricted_download_port,
)
self.assertEqual(expected_config, fixture.service_config)
- except:
+ except Exception:
self.attachLibrarianLog(fixture)
raise
diff --git a/lib/lp/services/profile/profile.py b/lib/lp/services/profile/profile.py
index 85e98f1..e98f17f 100644
--- a/lib/lp/services/profile/profile.py
+++ b/lib/lp/services/profile/profile.py
@@ -89,7 +89,7 @@ class Profiler:
self.profiler_lock.acquire(True) # Blocks.
try:
self.enable()
- except:
+ except Exception:
self.profiler_lock.release()
self.started = False
raise
diff --git a/lib/lp/services/spriteutils.py b/lib/lp/services/spriteutils.py
index 2ecd703..735f706 100644
--- a/lib/lp/services/spriteutils.py
+++ b/lib/lp/services/spriteutils.py
@@ -195,7 +195,7 @@ class SpriteUtil:
for x_position in range(width, max_sprite_width, width):
position[0] = x_position
combined_image.paste(sprite_image, tuple(position))
- except:
+ except Exception:
print(
"Error with image file %s" % sprite['filename'],
file=sys.stderr)
diff --git a/lib/lp/services/stacktrace.py b/lib/lp/services/stacktrace.py
index 6b3cacb..10b6764 100644
--- a/lib/lp/services/stacktrace.py
+++ b/lib/lp/services/stacktrace.py
@@ -29,7 +29,7 @@ def _try_except(callable, *args, **kwargs):
return callable(*args, **kwargs)
except EXPLOSIVE_ERRORS:
raise
- except:
+ except Exception:
if DEBUG_EXCEPTION_FORMATTER:
traceback.print_exc(file=sys.stderr)
# return None
@@ -100,7 +100,7 @@ def format_list(extracted_list):
item.append(_fmt(info))
except EXPLOSIVE_ERRORS:
raise
- except:
+ except Exception:
# The values above may not stringify properly, or who knows what
# else. Be defensive.
if DEBUG_EXCEPTION_FORMATTER:
@@ -170,7 +170,7 @@ def _get_frame_data(f, lineno):
warnings.append(warning)
except EXPLOSIVE_ERRORS:
raise
- except:
+ except Exception:
if DEBUG_EXCEPTION_FORMATTER:
traceback.print_exc(file=sys.stderr)
supplement_dict = dict(warnings=warnings, extra=extra)
diff --git a/lib/lp/services/twistedsupport/tests/test_processmonitor.py b/lib/lp/services/twistedsupport/tests/test_processmonitor.py
index 3ea4fd7..9ff30f6 100644
--- a/lib/lp/services/twistedsupport/tests/test_processmonitor.py
+++ b/lib/lp/services/twistedsupport/tests/test_processmonitor.py
@@ -35,7 +35,7 @@ def makeFailure(exception_factory, *args, **kwargs):
"""
try:
raise exception_factory(*args, **kwargs)
- except:
+ except Exception:
return failure.Failure()
diff --git a/lib/lp/services/twistedsupport/tests/test_xmlrpc.py b/lib/lp/services/twistedsupport/tests/test_xmlrpc.py
index ebe72e9..126d275 100644
--- a/lib/lp/services/twistedsupport/tests/test_xmlrpc.py
+++ b/lib/lp/services/twistedsupport/tests/test_xmlrpc.py
@@ -52,7 +52,7 @@ class TestTrapFault(TestCase):
"""Make a `Failure` from the given exception factory."""
try:
raise exception_factory(*args, **kwargs)
- except:
+ except Exception:
return Failure()
def assertRaisesFailure(self, failure, function, *args, **kwargs):
diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
index c012a1c..1e56ddb 100644
--- a/lib/lp/services/webapp/publication.py
+++ b/lib/lp/services/webapp/publication.py
@@ -268,7 +268,7 @@ class LaunchpadBrowserPublication(
request_txt = 'Exception converting request to string\n\n'
try:
request_txt += traceback.format_exc()
- except:
+ except Exception:
request_txt += 'Unable to render traceback!'
threadrequestfile.write(request_txt.encode('UTF-8'))
threadrequestfile.close()
diff --git a/lib/lp/soyuz/model/packagecopyjob.py b/lib/lp/soyuz/model/packagecopyjob.py
index 83c8b1f..4d8871c 100644
--- a/lib/lp/soyuz/model/packagecopyjob.py
+++ b/lib/lp/soyuz/model/packagecopyjob.py
@@ -647,7 +647,7 @@ class PlainPackageCopyJob(PackageCopyJobDerived):
pass
except (SuspendJobException, AdvisoryLockHeld):
raise
- except:
+ except Exception:
# Abort work done so far, but make sure that we commit the
# rejection to the PackageUpload.
transaction.abort()
diff --git a/lib/lp/soyuz/scripts/gina/changelog.py b/lib/lp/soyuz/scripts/gina/changelog.py
index ec20556..cc31594 100644
--- a/lib/lp/soyuz/scripts/gina/changelog.py
+++ b/lib/lp/soyuz/scripts/gina/changelog.py
@@ -70,7 +70,7 @@ def parse_changelog(changelines):
try:
(source, version, urgency) = parse_first_line(line.strip())
Version(six.ensure_text(version))
- except:
+ except Exception:
stanza.append(line)
#print "state0 Exception skip"
continue
diff --git a/lib/lp/testing/yuixhr.py b/lib/lp/testing/yuixhr.py
index c21831b..f66295b 100644
--- a/lib/lp/testing/yuixhr.py
+++ b/lib/lp/testing/yuixhr.py
@@ -335,7 +335,7 @@ class YUITestFixtureControllerView(LaunchpadView):
suite = suite_factory()
except EXPLOSIVE_ERRORS:
raise
- except:
+ except Exception:
warning = 'test_suite raises errors'
else:
case = None
@@ -400,7 +400,7 @@ class YUITestFixtureControllerView(LaunchpadView):
fixtures[fixture_name](self.request, data)
except EXPLOSIVE_ERRORS:
raise
- except:
+ except Exception:
self.request.response.setStatus(500)
result = ''.join(format_exception(*sys.exc_info()))
else:
@@ -421,7 +421,7 @@ class YUITestFixtureControllerView(LaunchpadView):
fixtures[fixture_name].teardown(self.request, data)
except EXPLOSIVE_ERRORS:
raise
- except:
+ except Exception:
self.request.response.setStatus(500)
result = ''.join(format_exception(*sys.exc_info()))
else:
diff --git a/lib/lp/translations/scripts/copy_distroseries_translations.py b/lib/lp/translations/scripts/copy_distroseries_translations.py
index 1196e43..59e1ab5 100644
--- a/lib/lp/translations/scripts/copy_distroseries_translations.py
+++ b/lib/lp/translations/scripts/copy_distroseries_translations.py
@@ -131,7 +131,7 @@ def copy_distroseries_translations(source, target, txn, logger,
copy_active_translations(
source, target, txn, logger, sourcepackagenames=spns,
skip_duplicates=skip_duplicates)
- except:
+ except Exception:
copy_failed = True
# Give us a fresh transaction for proper cleanup.
txn.abort()
@@ -142,7 +142,7 @@ def copy_distroseries_translations(source, target, txn, logger,
statekeeper.restore()
except Warning as message:
logger.warning(message)
- except:
+ except Exception:
logger.warning(
"Failed to restore hide_all_translations and "
"defer_translation_imports flags on %s after translations "
diff --git a/lib/lp/translations/scripts/language_pack.py b/lib/lp/translations/scripts/language_pack.py
index 0ef600f..b780bc8 100644
--- a/lib/lp/translations/scripts/language_pack.py
+++ b/lib/lp/translations/scripts/language_pack.py
@@ -143,7 +143,7 @@ def export(distroseries, component, update, force_utf8, logger):
# Store it in the tarball.
archive.add_file(path, contents)
- except:
+ except Exception:
logger.exception(
"Uncaught exception while exporting PO file %d" % pofile.id)
@@ -217,8 +217,8 @@ def export_language_pack(distribution_name, series_name, logger,
try:
filehandle, size = export(
distroseries, component, update, force_utf8, logger)
- except:
- # Bare except statements are used in order to prevent premature
+ except Exception:
+ # Base exception statements are used in order to prevent premature
# termination of the script.
logger.exception('Uncaught exception while exporting')
return None
@@ -263,8 +263,8 @@ def export_language_pack(distribution_name, series_name, logger,
except UploadFailed as e:
logger.error('Uploading to the Librarian failed: %s', e)
return None
- except:
- # Bare except statements are used in order to prevent premature
+ except Exception:
+ # Base exception statements are used in order to prevent premature
# termination of the script.
logger.exception(
'Uncaught exception while uploading to the Librarian')
diff --git a/scripts/script-monitor.py b/scripts/script-monitor.py
index 9671e7e..f859d54 100755
--- a/scripts/script-monitor.py
+++ b/scripts/script-monitor.py
@@ -99,7 +99,7 @@ def main():
msg.as_string())
smtp.close()
return 2
- except:
+ except Exception:
log.exception("Unhandled exception")
return 1
diff --git a/utilities/community-contributions.py b/utilities/community-contributions.py
index d9c59e2..da954e0 100755
--- a/utilities/community-contributions.py
+++ b/utilities/community-contributions.py
@@ -52,7 +52,7 @@ from bzrlib.osutils import format_date
try:
from editmoin import editshortcut
-except:
+except Exception:
sys.stderr.write("""ERROR: Unable to import from 'editmoin'. How to solve:
Get editmoin.py from launchpadlib's "contrib/" directory: