Colin Watson has proposed merging
lp:~cjwatson/launchpad/remove-unnecessary-exception-handling into lp:launchpad.
Commit message:
Remove Python 2.4-style KeyboardInterrupt/SystemExit handling.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/remove-unnecessary-exception-handling/+merge/370616
As of Python 2.5, it's better style to use:
except Exception:
...
... rather than:
except (KeyboardInterrupt, SystemExit):
raise
except:
...
Switch to this style across the board. The only unusual cases are some where
we really want very robust last-ditch exception handling, and in those cases I
used "except (GeneratorExit, Exception):" instead to make sure we catch any
weirdness.
--
Your team Launchpad code reviewers is requested to review the proposed merge of
lp:~cjwatson/launchpad/remove-unnecessary-exception-handling into lp:launchpad.
=== modified file 'lib/lp/archiveuploader/nascentupload.py'
--- lib/lp/archiveuploader/nascentupload.py 2018-12-04 15:01:51 +
+++ lib/lp/archiveuploader/nascentupload.py 2019-07-25 15:23:39 +
@@ -723,8 +723,6 @@
changes_file_object.close()
return True
-except (SystemExit, KeyboardInterrupt):
-raise
except QueueInconsistentStateError as e:
# A QueueInconsistentStateError is expected if the rejection
# is a routine rejection due to a bad package upload.
=== modified file 'lib/lp/archiveuploader/nascentuploadfile.py'
--- lib/lp/archiveuploader/nascentuploadfile.py 2019-05-24 17:12:50 +
+++ lib/lp/archiveuploader/nascentuploadfile.py 2019-07-25 15:23:39 +
@@ -555,9 +555,7 @@
deb_file = apt_inst.DebFile(self.filepath)
control_file = deb_file.control.extractdata("control")
control_lines = apt_pkg.TagSection(control_file, bytes=True)
-except (SystemExit, KeyboardInterrupt):
-raise
-except:
+except Exception:
yield UploadError(
"%s: extracting control file raised %s, giving up."
% (self.filename, sys.exc_type))
@@ -758,8 +756,6 @@
"far in the past (e.g. %s [%s])."
% (self.filename, len(ancient_files), first_file,
timestamp))
-except (SystemExit, KeyboardInterrupt):
-raise
except Exception as error:
# There is a very large number of places where we
# might get an exception while checking the timestamps.
=== modified file 'lib/lp/archiveuploader/uploadprocessor.py'
--- lib/lp/archiveuploader/uploadprocessor.py 2018-05-08 17:54:36 +
+++ lib/lp/archiveuploader/uploadprocessor.py 2019-07-25 15:23:39 +
@@ -369,8 +369,6 @@
"%s " % e)
logger.debug(
"UploadPolicyError escaped upload.process", exc_info=True)
-except (KeyboardInterrupt, SystemExit):
-raise
except EarlyReturnUploadError:
# An error occurred that prevented further error collection,
# add this fact to the list of errors.
@@ -510,9 +508,7 @@
try:
results.add(self.processChangesFile(
changes_file, self.processor.log))
-except (KeyboardInterrupt, SystemExit):
-raise
-except:
+except Exception:
info = sys.exc_info()
message = (
'Exception while processing upload %s' % self.upload_path)
@@ -680,9 +676,7 @@
[changes_file] = self.locateChangesFiles()
logger.debug("Considering changefile %s" % changes_file)
result = self.processChangesFile(changes_file, logger)
-except (KeyboardInterrupt, SystemExit):
-raise
-except:
+except Exception:
info = sys.exc_info()
message = (
'Exception while processing upload %s' % self.upload_path)
=== modified file 'lib/lp/bugs/scripts/bugimport.py'
--- lib/lp/bugs/scripts/bugimport.py 2019-06-18 16:52:56 +
+++ lib/lp/bugs/scripts/bugimport.py 2019-07-25 15:23:39 +
@@ -252,9 +252,7 @@
self.loadCache()
self.importBug(bugnode)
self.saveCache()
-except (SystemExit, KeyboardInterrupt):
-raise
-except:
+except Exception:
self.logger.exception(
'Could not import bug #%s', bugnode.get('id'))
ztm.abort()
=== modified file 'lib/lp/bugs/scripts/bugnotification.py'
--- lib/lp/bugs/scripts/bugnotification.py 2016-06-25 07:56:09 +
+++ lib/lp/bugs/scripts/bugnotification.py 2019-07-25 15:23:39 +
@@ -303,9 +303,7 @@
# being sent, so catch and log