← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/new-style-except into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/new-style-except into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/new-style-except/+merge/112727

Python 2.6 introduced a less ambiguous syntax for binding caught exceptions to local names, which is the only syntax available for this in Python 3:

  http://docs.python.org/whatsnew/2.6.html#pep-3110-exception-handling-changes

Since Launchpad no longer supports anything less than 2.6, I went through and excised all the old forms of 'except'.  This patch is large but essentially mechanical.
-- 
https://code.launchpad.net/~cjwatson/launchpad/new-style-except/+merge/112727
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/new-style-except into lp:launchpad.
=== modified file 'buildmailman.py'
--- buildmailman.py	2012-01-01 03:20:03 +0000
+++ buildmailman.py	2012-06-29 08:46:59 +0000
@@ -79,7 +79,7 @@
     # I think Linux does not ignore it -- better safe than sorry).
     try:
         os.makedirs(var_dir)
-    except OSError, e:
+    except OSError as e:
         if e.errno != errno.EEXIST:
             raise
     os.chown(var_dir, uid, gid)
@@ -190,7 +190,7 @@
     # deactivated lists.
     try:
         os.mkdir(os.path.join(Mailman.mm_cfg.VAR_PREFIX, 'backups'))
-    except OSError, e:
+    except OSError as e:
         if e.errno != errno.EEXIST:
             raise
 

=== modified file 'bzrplugins/lpserve/__init__.py'
--- bzrplugins/lpserve/__init__.py	2011-12-21 06:14:46 +0000
+++ bzrplugins/lpserve/__init__.py	2012-06-29 08:46:59 +0000
@@ -632,7 +632,7 @@
                 conn, client_addr = self._server_socket.accept()
             except self._socket_timeout:
                 pass  # Run shutdown and children checks.
-            except self._socket_error, e:
+            except self._socket_error as e:
                 if e.args[0] == errno.EINTR:
                     pass  # Run shutdown and children checks.
                 elif e.args[0] != errno.EBADF:
@@ -709,7 +709,7 @@
         while self._child_processes:
             try:
                 c_id, exit_code, rusage = os.wait3(os.WNOHANG)
-            except OSError, e:
+            except OSError as e:
                 if e.errno == errno.ECHILD:
                     # TODO: We handle this right now because the test suite
                     #       fakes a child, since we wanted to test some code
@@ -735,7 +735,7 @@
             # See [Decision #4]
             try:
                 sock.sendall('exited\n%s\n' % (exit_code,))
-            except (self._socket_timeout, self._socket_error), e:
+            except (self._socket_timeout, self._socket_error) as e:
                 # The client disconnected before we wanted them to,
                 # no big deal
                 trace.mutter('%s\'s socket already closed: %s' % (c_id, e))
@@ -791,7 +791,7 @@
         try:
             command_argv = self.command_to_argv(command)
             env = self.parse_env(env)
-        except Exception, e:
+        except Exception as e:
             # TODO: Log the traceback?
             self.log(client_addr, 'command or env parsing failed: %r'
                                   % (str(e),))
@@ -820,7 +820,7 @@
         elif request.startswith('child_connect_timeout '):
             try:
                 value = int(request.split(' ', 1)[1])
-            except ValueError, e:
+            except ValueError as e:
                 conn.sendall('FAILURE: %r\n' % (e,))
             else:
                 self._child_connect_timeout = value
@@ -877,7 +877,7 @@
         for pyname in libraries_to_preload:
             try:
                 __import__(pyname)
-            except ImportError, e:
+            except ImportError as e:
                 trace.mutter('failed to preload %s: %s' % (pyname, e))
 
     def _daemonize(self, pid_filename):
@@ -935,7 +935,7 @@
         if pid_file is not None:
             try:
                 os.remove(pid_file)
-            except (OSError, IOError), e:
+            except (OSError, IOError) as e:
                 trace.mutter('Failed to cleanup pid_file: %s\n%s'
                              % (pid_file, e))
 

=== modified file 'bzrplugins/lpserve/test_lpserve.py'
--- bzrplugins/lpserve/test_lpserve.py	2012-04-03 15:56:48 +0000
+++ bzrplugins/lpserve/test_lpserve.py	2012-06-29 08:46:59 +0000
@@ -641,12 +641,12 @@
     def _cleanup_daemon(self, pid, pid_filename):
         try:
             os.kill(pid, signal.SIGKILL)
-        except (OSError, IOError), e:
+        except (OSError, IOError) as e:
             trace.mutter('failed to kill pid %d, might be already dead: %s'
                          % (pid, e))
         try:
             os.remove(pid_filename)
-        except (OSError, IOError), e:
+        except (OSError, IOError) as e:
             if e.errno != errno.ENOENT:
                 trace.mutter('failed to remove %r: %s'
                              % (pid_filename, e))
@@ -697,7 +697,7 @@
         # message
         try:
             response = self.send_message_to_service('quit\n')
-        except socket.error, e:
+        except socket.error as e:
             # Ignore a failure to connect; the service must be
             # stopping/stopped already.
             response = None
@@ -714,7 +714,7 @@
         while tnow < tend:
             try:
                 os.kill(self.service_process, 0)
-            except (OSError, IOError), e:
+            except (OSError, IOError) as e:
                 if e.errno == errno.ESRCH:
                     # The process has successfully exited
                     stopped = True
@@ -729,7 +729,7 @@
                         unclean = True
                         try:
                             os.kill(self.service_process, sig)
-                        except (OSError, IOError), e:
+                        except (OSError, IOError) as e:
                             if e.errno == errno.ESRCH:
                                 stopped = True
                                 break

=== modified file 'cronscripts/process-mail.py'
--- cronscripts/process-mail.py	2012-01-01 03:14:54 +0000
+++ cronscripts/process-mail.py	2012-06-29 08:46:59 +0000
@@ -27,7 +27,7 @@
     def main(self):
         try:
             handleMail(self.txn)
-        except ComponentLookupError, lookup_error:
+        except ComponentLookupError as lookup_error:
             if lookup_error.args[0] != IMailBox:
                 raise
             raise LaunchpadScriptFailure(

=== modified file 'cronscripts/publishing/maintenance-check.py'
--- cronscripts/publishing/maintenance-check.py	2012-02-23 10:43:19 +0000
+++ cronscripts/publishing/maintenance-check.py	2012-06-29 08:46:59 +0000
@@ -431,7 +431,7 @@
                             pkg_support_time[pkgname] = support_time
             except:
                 logging.exception("can not parse line '%s'" % line)
-    except urllib2.HTTPError, e:
+    except urllib2.HTTPError as e:
         if e.code != 404:
             raise
         sys.stderr.write("hints-file: %s gave 404 error\n" % hints_file)

=== modified file 'cronscripts/reprocess-hwdb-submissions.py'
--- cronscripts/reprocess-hwdb-submissions.py	2012-01-01 03:14:54 +0000
+++ cronscripts/reprocess-hwdb-submissions.py	2012-06-29 08:46:59 +0000
@@ -69,7 +69,7 @@
         try:
             start_file = open(self.options.start_file, 'r+')
             start_id = start_file.read().strip()
-        except IOError, error:
+        except IOError as error:
             self.logger.error(
                 'Cannot access file %s: %s' % (
                     self.options.start_file, error))

=== modified file 'daemons/cache-database-replication-lag.py'
--- daemons/cache-database-replication-lag.py	2011-12-30 06:47:17 +0000
+++ daemons/cache-database-replication-lag.py	2012-06-29 08:46:59 +0000
@@ -50,7 +50,7 @@
                 else:
                     log.error("update_replication_lag_cache() failed.")
                 time.sleep(options.sleep)
-        except psycopg2.Error, x:
+        except psycopg2.Error as x:
             log.error("%s. Retrying.", str(x).strip())
             time.sleep(options.sleep)
 

=== modified file 'database/replication/new-slave.py'
--- database/replication/new-slave.py	2012-04-24 14:53:06 +0000
+++ database/replication/new-slave.py	2012-06-29 08:46:59 +0000
@@ -56,7 +56,7 @@
             "Opening source connection to '%s'" % source_connection_string)
         source_connection = psycopg2.connect(str(source_connection_string))
         source_connection.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
-    except psycopg2.Error, exception:
+    except psycopg2.Error as exception:
         parser.error("Unable to connect as %s (%s)" % (
             source_connection_string, str(exception).strip()))
 
@@ -92,7 +92,7 @@
     # Keep the connection as we need it.
     try:
         target_con = psycopg2.connect(str(target_connection_string))
-    except psycopg2.Error, exception:
+    except psycopg2.Error as exception:
         parser.error("Failed to connect using '%s' (%s)" % (
             target_connection_string, str(exception).strip()))
 
@@ -250,7 +250,7 @@
     try:
         # Test connection only.  We're not going to use it.
         psycopg2.connect(str(connection_string))
-    except psycopg2.Error, exception:
+    except psycopg2.Error as exception:
         parser.error("Failed to connect to using '%s' (%s)" % (
             connection_string, str(exception).strip()))
 

=== modified file 'database/schema/full-update.py'
--- database/schema/full-update.py	2012-01-01 03:20:03 +0000
+++ database/schema/full-update.py	2012-06-29 08:46:59 +0000
@@ -60,7 +60,7 @@
     except Exception:
         log.exception('Unhandled exception')
         return 1
-    except SystemExit, x:
+    except SystemExit as x:
         log.fatal("upgrade.py failed [%s]", x)
 
 
@@ -83,7 +83,7 @@
     except Exception:
         log.exception('Unhandled exception')
         return 1
-    except SystemExit, x:
+    except SystemExit as x:
         log.fatal("security.py failed [%s]", x)
 
 

=== modified file 'ez_setup.py'
--- ez_setup.py	2010-04-07 18:39:30 +0000
+++ ez_setup.py	2012-06-29 08:46:59 +0000
@@ -107,7 +107,7 @@
         return do_download()
     try:
         pkg_resources.require("setuptools>="+version); return
-    except pkg_resources.VersionConflict, e:
+    except pkg_resources.VersionConflict as e:
         if was_imported:
             print >>sys.stderr, (
             "The required version of setuptools (>=%s) is not available, and\n"

=== modified file 'lib/BeautifulSoup.py'
--- lib/BeautifulSoup.py	2009-08-04 17:44:01 +0000
+++ lib/BeautifulSoup.py	2012-06-29 08:46:59 +0000
@@ -1586,7 +1586,7 @@
             u = self._toUnicode(markup, proposed)
             self.markup = u       
             self.originalEncoding = proposed
-        except Exception, e:
+        except Exception as e:
             # print "That didn't work!"
             # print e
             return None        

=== modified file 'lib/contrib/apachelog.py'
--- lib/contrib/apachelog.py	2011-01-18 23:18:43 +0000
+++ lib/contrib/apachelog.py	2012-06-29 08:46:59 +0000
@@ -167,7 +167,7 @@
         self._pattern = '^' + ' '.join(subpatterns) + '$'
         try:
             self._regex = re.compile(self._pattern)
-        except Exception, e:
+        except Exception as e:
             raise ApacheLogParserError(e)
         
     def parse(self, line):

=== modified file 'lib/contrib/glock.py'
--- lib/contrib/glock.py	2010-03-30 03:11:26 +0000
+++ lib/contrib/glock.py	2012-06-29 08:46:59 +0000
@@ -177,7 +177,7 @@
                 options = fcntl.LOCK_EX|fcntl.LOCK_NB
             try:
                 fcntl.flock(self.fdlock, options)
-            except IOError, message: #(errno 13: perm. denied,
+            except IOError as message: #(errno 13: perm. denied,
                             #       36: Resource deadlock avoided)
                 if not blocking and self._errnoOf (message) == errno.EWOULDBLOCK:
                     raise LockAlreadyAcquired('Lock %s already acquired by '
@@ -230,7 +230,7 @@
                 try:
                     win32event.ReleaseMutex(self.mutex)
                     #print "released mutex"
-                except pywintypes.error, e:
+                except pywintypes.error as e:
                     errCode, fctName, errMsg =  e.args
                     if errCode == 288:
                         raise NotOwner("Attempt to release somebody else's lock")

=== modified file 'lib/launchpad_loggerhead/app.py'
--- lib/launchpad_loggerhead/app.py	2012-02-03 05:35:54 +0000
+++ lib/launchpad_loggerhead/app.py	2012-06-29 08:46:59 +0000
@@ -192,7 +192,7 @@
             try:
                 transport_type, info, trail = self.branchfs.translatePath(
                     user, urlutils.escape(path))
-            except xmlrpclib.Fault, f:
+            except xmlrpclib.Fault as f:
                 if check_fault(f, faults.PathTranslationError):
                     raise HTTPNotFound()
                 elif check_fault(f, faults.PermissionDenied):
@@ -275,7 +275,7 @@
             try:
                 bzr_branch = safe_open(
                     lp_server.get_url().strip(':/'), branch_url)
-            except errors.NotBranchError, err:
+            except errors.NotBranchError as err:
                 self.log.warning('Not a branch: %s', err)
                 raise HTTPNotFound()
             bzr_branch.lock_read()

=== modified file 'lib/lp/app/browser/folder.py'
--- lib/lp/app/browser/folder.py	2012-01-01 02:58:52 +0000
+++ lib/lp/app/browser/folder.py	2012-06-29 08:46:59 +0000
@@ -88,7 +88,7 @@
         name = os.path.basename(filename)
         try:
             fileobj = File(filename, name)
-        except IOError, ioerror:
+        except IOError as ioerror:
             expected = (errno.ENOENT, errno.EISDIR, errno.ENOTDIR)
             if ioerror.errno in expected:
                 # No such file or is a directory.

=== modified file 'lib/lp/app/browser/launchpad.py'
--- lib/lp/app/browser/launchpad.py	2012-06-15 04:07:30 +0000
+++ lib/lp/app/browser/launchpad.py	2012-06-29 08:46:59 +0000
@@ -623,7 +623,7 @@
             target_url = canonical_url(branch)
             if trailing is not None:
                 target_url = urlappend(target_url, trailing)
-        except (NoLinkedBranch), e:
+        except (NoLinkedBranch) as e:
             # A valid ICanHasLinkedBranch target exists but there's no
             # branch or it's not visible.
 
@@ -636,7 +636,7 @@
             self.request.response.addNotification(
                 "The target %s does not have a linked branch." % path)
         except (CannotHaveLinkedBranch, InvalidNamespace,
-                InvalidProductName, NotFoundError), e:
+                InvalidProductName, NotFoundError) as e:
             # If are aren't arriving at this invalid branch URL from another
             # page then we just raise a NotFoundError to generate a 404,
             # otherwise we end up in a bad recursion loop. The target url will

=== modified file 'lib/lp/app/browser/tales.py'
--- lib/lp/app/browser/tales.py	2012-06-15 16:23:50 +0000
+++ lib/lp/app/browser/tales.py	2012-06-29 08:46:59 +0000
@@ -322,7 +322,7 @@
             except NoCanonicalUrl:
                 menu = None
             return self._getMenuLinksAndAttributes(menu)
-        except AttributeError, e:
+        except AttributeError as e:
             # If this method gets an AttributeError, we rethrow it as a
             # AssertionError. Otherwise, zope will hide the root cause
             # of the error and just say that "navigation" can't be traversed.

=== modified file 'lib/lp/app/widgets/date.py'
--- lib/lp/app/widgets/date.py	2012-01-01 02:58:52 +0000
+++ lib/lp/app/widgets/date.py	2012-06-29 08:46:59 +0000
@@ -340,7 +340,7 @@
         for fmt in self.supported_input_formats:
             try:
                 datetime.strptime(input.strip(), fmt)
-            except (ValueError), e:
+            except (ValueError) as e:
                 if 'unconverted data remains' in str(e):
                     return
                 else:
@@ -397,7 +397,7 @@
             micro = round(micro * 1000000)
             dt = datetime(year, month, day,
                           hour, minute, int(second), int(micro))
-        except (DateTimeError, ValueError, IndexError), v:
+        except (DateTimeError, ValueError, IndexError) as v:
             raise ConversionError('Invalid date value', v)
         return self.time_zone.localize(dt)
 

=== modified file 'lib/lp/app/widgets/image.py'
--- lib/lp/app/widgets/image.py	2012-01-01 02:58:52 +0000
+++ lib/lp/app/widgets/image.py	2012-06-29 08:46:59 +0000
@@ -138,7 +138,7 @@
             self._image = form.getOne(self.image_widget.name)
             try:
                 self.context.validate(self._image)
-            except ValidationError, v:
+            except ValidationError as v:
                 self._error = WidgetInputError(self.name, self.label, v)
                 raise self._error
             self._image.seek(0)

=== modified file 'lib/lp/app/widgets/launchpadtarget.py'
--- lib/lp/app/widgets/launchpadtarget.py	2012-02-22 00:04:43 +0000
+++ lib/lp/app/widgets/launchpadtarget.py	2012-06-29 08:46:59 +0000
@@ -187,7 +187,7 @@
         try:
             if self.hasInput():
                 self.getInputValue()
-        except InputErrors, error:
+        except InputErrors as error:
             self._error = error
         return super(LaunchpadTargetWidget, self).error()
 

=== modified file 'lib/lp/app/widgets/tests/test_datetime.py'
--- lib/lp/app/widgets/tests/test_datetime.py	2012-06-14 05:18:22 +0000
+++ lib/lp/app/widgets/tests/test_datetime.py	2012-06-29 08:46:59 +0000
@@ -38,7 +38,7 @@
         fmt = "%Y-%m-%d"
         try:
             datetime.strptime(test_str, fmt)
-        except (ValueError,), e:
+        except (ValueError,) as e:
             self.assertTrue('unconverted data' in str(e))
 
     def test_whitespace_does_not_trick_validation(self):

=== modified file 'lib/lp/app/widgets/textwidgets.py'
--- lib/lp/app/widgets/textwidgets.py	2011-11-17 17:18:32 +0000
+++ lib/lp/app/widgets/textwidgets.py	2012-06-29 08:46:59 +0000
@@ -106,7 +106,7 @@
             micro = round(micro * 1000000)
             dt = datetime.datetime(year, month, day,
                                    hour, minute, int(second), int(micro))
-        except (DateTimeError, ValueError, IndexError), v:
+        except (DateTimeError, ValueError, IndexError) as v:
             raise ConversionError('Invalid date value', v)
         tz = pytz.timezone(self.timeZoneName)
         return tz.localize(dt)

=== modified file 'lib/lp/archivepublisher/customupload.py'
--- lib/lp/archivepublisher/customupload.py	2012-05-30 10:25:43 +0000
+++ lib/lp/archivepublisher/customupload.py	2012-06-29 08:46:59 +0000
@@ -206,7 +206,7 @@
                     tar.extract(tarinfo, self.tmpdir)
             finally:
                 tar.close()
-        except tarfile.TarError, exc:
+        except tarfile.TarError as exc:
             raise CustomUploadTarballTarError(self.tarfile_path, exc)
 
     def shouldInstall(self, filename):

=== modified file 'lib/lp/archivepublisher/deathrow.py'
--- lib/lp/archivepublisher/deathrow.py	2011-12-30 06:14:56 +0000
+++ lib/lp/archivepublisher/deathrow.py	2012-06-29 08:46:59 +0000
@@ -277,11 +277,11 @@
             try:
                 bytes += self._removeFile(
                     component_name, source_name, file_name)
-            except NotInPool, info:
+            except NotInPool as info:
                 # It's safe for us to let this slide because it means that
                 # the file is already gone.
                 self.logger.debug(str(info))
-            except MissingSymlinkInPool, info:
+            except MissingSymlinkInPool as info:
                 # This one is a little more worrying, because an expected
                 # symlink has vanished from the pool/ (could be a code
                 # mistake) but there is nothing we can do about it at this

=== modified file 'lib/lp/archivepublisher/debversion.py'
--- lib/lp/archivepublisher/debversion.py	2010-08-20 20:31:18 +0000
+++ lib/lp/archivepublisher/debversion.py	2012-06-29 08:46:59 +0000
@@ -65,7 +65,7 @@
 
         try:
             changelog.Version.__init__(self, ver)
-        except ValueError, e:
+        except ValueError as e:
             raise VersionError(e)
 
         if self.epoch is not None:

=== modified file 'lib/lp/archivepublisher/dist_upgrader.py'
--- lib/lp/archivepublisher/dist_upgrader.py	2012-05-30 10:25:43 +0000
+++ lib/lp/archivepublisher/dist_upgrader.py	2012-06-29 08:46:59 +0000
@@ -90,7 +90,7 @@
         directory_name = filename.split(os.path.sep)[0]
         try:
             version = make_version(directory_name)
-        except BadUpstreamError, exc:
+        except BadUpstreamError as exc:
             raise DistUpgraderBadVersion(self.tarfile_path, exc)
         return version and not filename.startswith('current')
 

=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py	2012-06-19 02:33:21 +0000
+++ lib/lp/archivepublisher/publishing.py	2012-06-29 08:46:59 +0000
@@ -747,7 +747,7 @@
                 continue
             try:
                 shutil.rmtree(directory)
-            except (shutil.Error, OSError), e:
+            except (shutil.Error, OSError) as e:
                 self.log.warning(
                     "Failed to delete directory '%s' for archive "
                     "'%s/%s'\n%s" % (

=== modified file 'lib/lp/archivepublisher/scripts/generate_extra_overrides.py'
--- lib/lp/archivepublisher/scripts/generate_extra_overrides.py	2012-05-21 13:01:20 +0000
+++ lib/lp/archivepublisher/scripts/generate_extra_overrides.py	2012-06-29 08:46:59 +0000
@@ -167,7 +167,7 @@
                     self.logger.warning(
                         "Skipping empty seed structure for %s.%s",
                         flavour, series_name)
-            except SeedError, e:
+            except SeedError as e:
                 self.logger.warning(
                     "Failed to fetch seeds for %s.%s: %s",
                     flavour, series_name, e)

=== modified file 'lib/lp/archiveuploader/changesfile.py'
--- lib/lp/archiveuploader/changesfile.py	2011-05-20 08:04:19 +0000
+++ lib/lp/archiveuploader/changesfile.py	2012-06-29 08:46:59 +0000
@@ -145,12 +145,12 @@
             # doing ensurePerson() for buildds and sync owners.
             try:
                 self.maintainer = self.parseAddress(self._dict['Maintainer'])
-            except UploadError, error:
+            except UploadError as error:
                 yield error
 
         try:
             self.changed_by = self.parseAddress(self._dict['Changed-By'])
-        except UploadError, error:
+        except UploadError as error:
             yield error
 
     def isCustom(self, component_and_section):
@@ -204,7 +204,7 @@
 
                     if cls == DSCFile:
                         self.dsc = file_instance
-            except UploadError, error:
+            except UploadError as error:
                 yield error
             else:
                 files.append(file_instance)

=== modified file 'lib/lp/archiveuploader/dscfile.py'
--- lib/lp/archiveuploader/dscfile.py	2012-01-06 11:08:30 +0000
+++ lib/lp/archiveuploader/dscfile.py	2012-06-29 08:46:59 +0000
@@ -96,7 +96,7 @@
     """
     try:
         shutil.rmtree(unpacked_dir)
-    except OSError, error:
+    except OSError as error:
         if errno.errorcode[error.errno] != 'EACCES':
             raise UploadError(
                 "couldn't remove tmp dir %s: code %s" % (
@@ -132,7 +132,7 @@
         try:
             with open(self.filepath, 'rb') as f:
                 self.raw_content = f.read()
-        except IOError, error:
+        except IOError as error:
             raise UploadError(
                 "Unable to read %s: %s" % (self.filename, error))
 
@@ -145,7 +145,7 @@
         try:
             self._dict = parse_tagfile_content(
                 self.parsed_content, filename=self.filepath)
-        except TagFileParseError, error:
+        except TagFileParseError as error:
             raise UploadError(
                 "Unable to parse %s: %s" % (self.filename, error))
 
@@ -164,7 +164,7 @@
         try:
             sig = getUtility(IGPGHandler).getVerifiedSignatureResilient(
                 content)
-        except GPGVerificationError, error:
+        except GPGVerificationError as error:
             raise UploadError(
                 "GPG verification of %s failed: %s" % (
                 filename, str(error)))
@@ -195,7 +195,7 @@
         try:
             (rfc822, rfc2047, name, email) = safe_fix_maintainer(
                 addr, fieldname)
-        except ParseMaintError, error:
+        except ParseMaintError as error:
             raise UploadError(str(error))
 
         person = getUtility(IPersonSet).getByEmail(email)
@@ -340,7 +340,7 @@
         # Check size and checksum of the DSC file itself
         try:
             self.checkSizeAndCheckSum()
-        except UploadError, error:
+        except UploadError as error:
             yield error
 
         files = []
@@ -358,7 +358,7 @@
             try:
                 file_instance = DSCUploadedFile(
                     filepath, digest, size, self.policy, self.logger)
-            except UploadError, error:
+            except UploadError as error:
                 yield error
             else:
                 files.append(file_instance)
@@ -389,7 +389,7 @@
                     apt_pkg.parse_src_depends(field)
                 except (SystemExit, KeyboardInterrupt):
                     raise
-                except Exception, error:
+                except Exception as error:
                     # Swallow everything apt_pkg throws at us because
                     # it is not desperately pythonic and can raise odd
                     # or confusing exceptions at times and is out of
@@ -505,7 +505,7 @@
             try:
                 library_file, file_archive = self._getFileByName(
                     sub_dsc_file.filename)
-            except NotFoundError, error:
+            except NotFoundError as error:
                 library_file = None
                 file_archive = None
             else:
@@ -573,7 +573,7 @@
 
         try:
             unpacked_dir = unpack_source(self.filepath)
-        except DpkgSourceError, e:
+        except DpkgSourceError as e:
             yield UploadError(
                 "dpkg-source failed for %s [return: %s]\n"
                 "[dpkg-source output: %s]"
@@ -600,18 +600,18 @@
             # processing.
             try:
                 self.copyright = find_copyright(unpacked_dir, self.logger)
-            except UploadError, error:
+            except UploadError as error:
                 yield error
                 return
-            except UploadWarning, warning:
+            except UploadWarning as warning:
                 yield warning
 
             try:
                 self.changelog = find_changelog(unpacked_dir, self.logger)
-            except UploadError, error:
+            except UploadError as error:
                 yield error
                 return
-            except UploadWarning, warning:
+            except UploadWarning as warning:
                 yield warning
         finally:
             self.logger.debug("Cleaning up source tree.")
@@ -724,7 +724,7 @@
         """Check Sub DSCFile mentioned size & checksum."""
         try:
             self.checkSizeAndCheckSum()
-        except UploadError, error:
+        except UploadError as error:
             yield error
 
 

=== modified file 'lib/lp/archiveuploader/nascentupload.py'
--- lib/lp/archiveuploader/nascentupload.py	2012-06-26 12:25:42 +0000
+++ lib/lp/archiveuploader/nascentupload.py	2012-06-29 08:46:59 +0000
@@ -388,9 +388,9 @@
         """
         try:
             callable()
-        except UploadError, error:
+        except UploadError as error:
             self.reject("".join(error.args))
-        except UploadWarning, error:
+        except UploadWarning as error:
             self.warn("".join(error.args))
 
     def run_and_collect_errors(self, callable):
@@ -856,14 +856,14 @@
 
         except (SystemExit, KeyboardInterrupt):
             raise
-        except QueueInconsistentStateError, e:
+        except QueueInconsistentStateError as e:
             # A QueueInconsistentStateError is expected if the rejection
             # is a routine rejection due to a bad package upload.
             # Log at info level so LaunchpadCronScript doesn't generate an
             # OOPS.
             func = self.logger.info
             return self._reject_with_logging(e, notify, func)
-        except Exception, e:
+        except Exception as e:
             # Any exception which occurs while processing an accept will
             # cause a rejection to occur. The exception is logged in the
             # reject message rather than being swallowed up.

=== modified file 'lib/lp/archiveuploader/nascentuploadfile.py'
--- lib/lp/archiveuploader/nascentuploadfile.py	2012-05-25 15:31:50 +0000
+++ lib/lp/archiveuploader/nascentuploadfile.py	2012-06-29 08:46:59 +0000
@@ -724,7 +724,7 @@
         tar_checker.reset()
         try:
             deb_file = apt_inst.DebFile(self.filepath)
-        except SystemError, error:
+        except SystemError as error:
             # We get an error from the constructor if the .deb does not
             # contain all the expected top-level members (debian-binary,
             # control.tar.gz, and data.tar.*).
@@ -753,7 +753,7 @@
                         timestamp))
         except (SystemExit, KeyboardInterrupt):
             raise
-        except Exception, error:
+        except Exception as error:
             # There is a very large number of places where we
             # might get an exception while checking the timestamps.
             # Many of them come from apt_inst/apt_pkg and they are

=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_uploadprocessor.py	2012-03-16 18:17:46 +0000
+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py	2012-06-29 08:46:59 +0000
@@ -235,7 +235,7 @@
         """
         try:
             callableObj(*args, **kwargs)
-        except excClass, error:
+        except excClass as error:
             return error
         else:
             if getattr(excClass, '__name__', None) is not None:

=== modified file 'lib/lp/archiveuploader/uploadprocessor.py'
--- lib/lp/archiveuploader/uploadprocessor.py	2012-01-01 02:58:52 +0000
+++ lib/lp/archiveuploader/uploadprocessor.py	2012-06-29 08:46:59 +0000
@@ -191,7 +191,7 @@
                     continue
                 try:
                     handler = UploadHandler.forProcessor(self, fsroot, upload)
-                except CannotGetBuild, e:
+                except CannotGetBuild as e:
                     self.log.warn(e)
                 else:
                     handler.process()
@@ -225,7 +225,7 @@
         # be able to do so.
         try:
             os.chmod(lockfile_path, mode | stat.S_IWGRP)
-        except OSError, err:
+        except OSError as err:
             self.log.debug('Could not fix the lockfile permission: %s' % err)
 
         try:
@@ -326,7 +326,7 @@
         try:
             (distribution, suite_name,
              archive) = parse_upload_path(relative_path)
-        except UploadPathError, e:
+        except UploadPathError as e:
             # pick some defaults to create the NascentUpload() object.
             # We will be rejecting the upload so it doesn matter much.
             distribution = getUtility(IDistributionSet)['ubuntu']
@@ -337,7 +337,7 @@
                      extra_info=(
                          "Please update your dput/dupload configuration "
                          "and then re-upload.")))
-        except PPAUploadPathError, e:
+        except PPAUploadPathError as e:
             # Again, pick some defaults but leave a hint for the rejection
             # emailer that it was a PPA failure.
             distribution = getUtility(IDistributionSet)['ubuntu']
@@ -408,7 +408,7 @@
 
             try:
                 self._processUpload(upload)
-            except UploadPolicyError, e:
+            except UploadPolicyError as e:
                 upload.reject("UploadPolicyError escaped upload.process: "
                               "%s " % e)
                 logger.debug(
@@ -421,7 +421,7 @@
                 upload.reject(
                     "Further error processing not possible because of "
                     "a critical previous error.")
-            except Exception, e:
+            except Exception as e:
                 # In case of unexpected unhandled exception, we'll
                 # *try* to reject the upload. This may fail and cause
                 # a further exception, depending on the state of the

=== modified file 'lib/lp/blueprints/browser/specification.py'
--- lib/lp/blueprints/browser/specification.py	2012-05-17 07:46:56 +0000
+++ lib/lp/blueprints/browser/specification.py	2012-06-29 08:46:59 +0000
@@ -1307,7 +1307,7 @@
         try:
             image = self.renderGraphvizGraph('png')
             self.request.response.setHeader('Content-type', 'image/png')
-        except (ProblemRenderingGraph, OSError), error:
+        except (ProblemRenderingGraph, OSError) as error:
             # The subprocess or command can raise errors that might not
             # occur if we used a Python bindings for GraphViz. Instead of
             # sending the generated image, return the fail-over image
@@ -1327,7 +1327,7 @@
         """Render the image and image map tags for this dependency graph."""
         try:
             image_map = self.renderGraphvizGraph('cmapx').decode('UTF-8')
-        except (ProblemRenderingGraph, OSError), error:
+        except (ProblemRenderingGraph, OSError) as error:
             # The subprocess or command can raise errors that might not
             # occur if we used a Python bindings for GraphViz. Instead
             # of rendering an image map, return an explanation that the

=== modified file 'lib/lp/bugs/adapters/treelookup.py'
--- lib/lp/bugs/adapters/treelookup.py	2009-06-25 00:40:31 +0000
+++ lib/lp/bugs/adapters/treelookup.py	2012-06-29 08:46:59 +0000
@@ -226,7 +226,7 @@
                 elif len(more) >= 1:
                     try:
                         return branch.result.find(*more)
-                    except KeyError, ex:
+                    except KeyError as ex:
                         raise KeyError((key,) + ex.args)
                 else:
                     raise KeyError(key)

=== modified file 'lib/lp/bugs/browser/bugalsoaffects.py'
--- lib/lp/bugs/browser/bugalsoaffects.py	2012-06-12 16:09:33 +0000
+++ lib/lp/bugs/browser/bugalsoaffects.py	2012-06-29 08:46:59 +0000
@@ -712,7 +712,7 @@
         bug_url = data.get('bug_url').strip()
         try:
             getUtility(IBugWatchSet).extractBugTrackerAndBug(bug_url)
-        except NoBugTrackerFound, error:
+        except NoBugTrackerFound as error:
             getUtility(IBugTrackerSet).ensureBugTracker(
                 error.base_url, self.user, error.bugtracker_type)
         self.next_step = self._next_step

=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py	2012-06-22 05:52:17 +0000
+++ lib/lp/bugs/browser/bugtarget.py	2012-06-29 08:46:59 +0000
@@ -1167,7 +1167,7 @@
         """Make sure some keywords are provided."""
         try:
             data['title'] = self.widgets['title'].getInputValue()
-        except InputErrors, error:
+        except InputErrors as error:
             self.setFieldError("title", "A summary is required.")
             return [error]
 

=== modified file 'lib/lp/bugs/browser/widgets/bug.py'
--- lib/lp/bugs/browser/widgets/bug.py	2012-06-28 16:00:11 +0000
+++ lib/lp/bugs/browser/widgets/bug.py	2012-06-29 08:46:59 +0000
@@ -103,7 +103,7 @@
     def getInputValue(self):
         try:
             return self._getInputValue()
-        except WidgetInputError, input_error:
+        except WidgetInputError as input_error:
             # The standard error message isn't useful at all. We look to
             # see if it's a ConstraintNotSatisfied error and change it
             # to a better one. For simplicity, we care only about the

=== modified file 'lib/lp/bugs/browser/widgets/bugtask.py'
--- lib/lp/bugs/browser/widgets/bugtask.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/widgets/bugtask.py	2012-06-29 08:46:59 +0000
@@ -333,14 +333,14 @@
                 bugtask = self.context.context
                 return bugtask.bug.addWatch(
                     bugtracker, remote_bug, getUtility(ILaunchBag).user)
-            except WidgetInputError, error:
+            except WidgetInputError as error:
                 # Prefix the error with the widget name, since the error
                 # will be display at the top of the page, and not right
                 # next to the widget.
                 raise WidgetInputError(
                     self.context.__name__, self.label,
                     'Remote Bug: %s' % error.doc())
-            except (NoBugTrackerFound, UnrecognizedBugTrackerURL), error:
+            except (NoBugTrackerFound, UnrecognizedBugTrackerURL) as error:
                 raise WidgetInputError(
                     self.context.__name__, self.label,
                     'Invalid bug tracker URL.')

=== modified file 'lib/lp/bugs/externalbugtracker/base.py'
--- lib/lp/bugs/externalbugtracker/base.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/externalbugtracker/base.py	2012-06-29 08:46:59 +0000
@@ -245,7 +245,7 @@
         """
         try:
             return self.urlopen(page, data)
-        except (urllib2.HTTPError, urllib2.URLError), val:
+        except (urllib2.HTTPError, urllib2.URLError) as val:
             raise BugTrackerConnectError(self.baseurl, val)
 
     def _getPage(self, page):

=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py	2012-01-06 11:08:30 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py	2012-06-29 08:46:59 +0000
@@ -88,7 +88,7 @@
             # We try calling Bugzilla.version() on the remote
             # server because it's the most lightweight method there is.
             remote_version = proxy.Bugzilla.version()
-        except xmlrpclib.Fault, fault:
+        except xmlrpclib.Fault as fault:
             # 'Client' is a hangover. Either Bugzilla or the Perl
             # XML-RPC lib in use returned it as faultCode. It's wrong,
             # but it's known wrongness, so we recognize it here.
@@ -96,7 +96,7 @@
                 return False
             else:
                 raise
-        except xmlrpclib.ProtocolError, error:
+        except xmlrpclib.ProtocolError as error:
             # We catch 404s, which occur when xmlrpc.cgi doesn't exist
             # on the remote server, and 500s, which sometimes occur when
             # an invalid request is made to the remote server. We allow
@@ -105,7 +105,7 @@
                 return False
             else:
                 raise
-        except (xmlrpclib.ResponseError, xml.parsers.expat.ExpatError):
+        except xmlrpclib.ResponseError as xml.parsers.expat.ExpatError:
             # The server returned an unparsable response.
             return False
         else:
@@ -130,7 +130,7 @@
             # We try calling Launchpad.plugin_version() on the remote
             # server because it's the most lightweight method there is.
             proxy.Launchpad.plugin_version()
-        except xmlrpclib.Fault, fault:
+        except xmlrpclib.Fault as fault:
             # 'Client' is a hangover. Either Bugzilla or the Perl
             # XML-RPC lib in use returned it as faultCode. It's wrong,
             # but it's known wrongness, so we recognize it here.
@@ -138,7 +138,7 @@
                 return False
             else:
                 raise
-        except xmlrpclib.ProtocolError, error:
+        except xmlrpclib.ProtocolError as error:
             # We catch 404s, which occur when xmlrpc.cgi doesn't exist
             # on the remote server, and 500s, which sometimes occur when
             # the Launchpad Plugin isn't installed. Everything else we
@@ -200,7 +200,7 @@
         version_xml = self._getPage('xml.cgi?id=1')
         try:
             document = self._parseDOMString(version_xml)
-        except xml.parsers.expat.ExpatError, e:
+        except xml.parsers.expat.ExpatError as e:
             raise BugTrackerConnectError(self.baseurl,
                 "Failed to parse output when probing for version: %s" % e)
         bugzilla = document.getElementsByTagName("bugzilla")
@@ -403,7 +403,7 @@
 
         try:
             document = self._parseDOMString(buglist_xml)
-        except xml.parsers.expat.ExpatError, e:
+        except xml.parsers.expat.ExpatError as e:
             raise UnparsableBugData(
                 "Failed to parse XML description for %s bugs %s: %s"
                 % (self.baseurl, bug_ids, e))
@@ -533,7 +533,7 @@
     def decorator(self, *args, **kwargs):
         try:
             return func(self, *args, **kwargs)
-        except xmlrpclib.Fault, fault:
+        except xmlrpclib.Fault as fault:
             # Catch authentication errors only.
             if fault.faultCode != 410:
                 raise
@@ -604,7 +604,7 @@
         """
         try:
             self.xmlrpc_proxy.User.login(self.credentials)
-        except xmlrpclib.Fault, fault:
+        except xmlrpclib.Fault as fault:
             raise BugTrackerAuthenticationError(
                 self.baseurl,
                 "Fault %s: %s" % (fault.faultCode, fault.faultString))
@@ -934,12 +934,12 @@
         try:
             self.xmlrpc_proxy.Launchpad.login(
                 {'token': token_text})
-        except xmlrpclib.Fault, fault:
+        except xmlrpclib.Fault as fault:
             message = 'XML-RPC Fault: %s "%s"' % (
                 fault.faultCode, fault.faultString)
             raise BugTrackerAuthenticationError(
                 self.baseurl, message)
-        except xmlrpclib.ProtocolError, error:
+        except xmlrpclib.ProtocolError as error:
             message = 'Protocol error: %s "%s"' % (
                 error.errcode, error.errmsg)
             raise BugTrackerAuthenticationError(

=== modified file 'lib/lp/bugs/externalbugtracker/mantis.py'
--- lib/lp/bugs/externalbugtracker/mantis.py	2012-01-06 11:08:30 +0000
+++ lib/lp/bugs/externalbugtracker/mantis.py	2012-06-29 08:46:59 +0000
@@ -159,7 +159,7 @@
                 if bug is not None:
                     bugs[bug['id']] = bug
             return bugs
-        except csv.Error, error:
+        except csv.Error as error:
             raise UnparsableBugData("Exception parsing CSV file: %s." % error)
 
 
@@ -254,7 +254,7 @@
         # what's being viewed.
         try:
             csv_data = self._getPage("csv_export.php")
-        except BugTrackerConnectError, value:
+        except BugTrackerConnectError as value:
             # Some Mantis installations simply return a 500 error
             # when the csv_export.php page is accessed. Since the
             # bug data may be nevertheless available from ordinary

=== modified file 'lib/lp/bugs/externalbugtracker/rt.py'
--- lib/lp/bugs/externalbugtracker/rt.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/externalbugtracker/rt.py	2012-06-29 08:46:59 +0000
@@ -85,7 +85,7 @@
         # can't.
         try:
             self._logIn(opener)
-        except (urllib2.HTTPError, urllib2.URLError), error:
+        except (urllib2.HTTPError, urllib2.URLError) as error:
             raise BugTrackerConnectError('%s/' % self.baseurl,
                 "Unable to authenticate with remote RT service: "
                 "Could not submit login form: " +
@@ -110,7 +110,7 @@
         query_url = '%s/%s' % (self.baseurl, ticket_url)
         try:
             bug_data = self.urlopen(query_url)
-        except urllib2.HTTPError, error:
+        except urllib2.HTTPError as error:
             raise BugTrackerConnectError(ticket_url, error.message)
 
         # We use the first line of the response to ensure that we've
@@ -146,7 +146,7 @@
         try:
             bug_data = self.urlopen(query_url, urllib.urlencode(
                 request_params))
-        except urllib2.HTTPError, error:
+        except urllib2.HTTPError as error:
             raise BugTrackerConnectError(query_url, error.message)
 
         # We use the first line of the response to ensure that we've

=== modified file 'lib/lp/bugs/externalbugtracker/trac.py'
--- lib/lp/bugs/externalbugtracker/trac.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/externalbugtracker/trac.py	2012-06-29 08:46:59 +0000
@@ -70,14 +70,14 @@
         auth_url = urlappend(base_auth_url, 'check')
         try:
             response = self.urlopen(auth_url)
-        except urllib2.HTTPError, error:
+        except urllib2.HTTPError as error:
             # If the error is HTTP 401 Unauthorized then we're
             # probably talking to the LP plugin.
             if error.code == 401:
                 return TracLPPlugin(self.baseurl)
             else:
                 return self
-        except urllib2.URLError, error:
+        except urllib2.URLError as error:
             return self
         else:
             # If the response contains a trac_auth cookie then we're
@@ -301,7 +301,7 @@
     def decorator(self, *args, **kwargs):
         try:
             return func(self, *args, **kwargs)
-        except xmlrpclib.ProtocolError, error:
+        except xmlrpclib.ProtocolError as error:
             # Catch authentication errors only.
             if error.errcode != 403:
                 raise
@@ -376,7 +376,7 @@
 
         try:
             self._fetchPage(auth_url)
-        except BugTrackerConnectError, e:
+        except BugTrackerConnectError as e:
             raise BugTrackerAuthenticationError(self.baseurl, e.error)
 
     @ensure_no_transaction
@@ -489,7 +489,7 @@
         try:
             timestamp, lp_bug_id = self._server.launchpad.get_launchpad_bug(
                 remote_bug)
-        except xmlrpclib.Fault, fault:
+        except xmlrpclib.Fault as fault:
             # Deal with "Ticket does not exist" faults. We re-raise
             # anything else, since they're a sign of a bigger problem.
             if fault.faultCode == FAULT_TICKET_NOT_FOUND:
@@ -520,7 +520,7 @@
         try:
             self._server.launchpad.set_launchpad_bug(
                 remote_bug, launchpad_bug_id)
-        except xmlrpclib.Fault, fault:
+        except xmlrpclib.Fault as fault:
             # Deal with "Ticket does not exist" faults. We re-raise
             # anything else, since they're a sign of a bigger problem.
             if fault.faultCode == FAULT_TICKET_NOT_FOUND:

=== modified file 'lib/lp/bugs/externalbugtracker/xmlrpc.py'
--- lib/lp/bugs/externalbugtracker/xmlrpc.py	2012-06-28 10:41:18 +0000
+++ lib/lp/bugs/externalbugtracker/xmlrpc.py	2012-06-29 08:46:59 +0000
@@ -109,7 +109,7 @@
         request = Request(url, request_body, headers)
         try:
             response = self.opener.open(request).read()
-        except HTTPError, he:
+        except HTTPError as he:
             raise ProtocolError(
                 request.get_full_url(), he.code, he.msg, he.hdrs)
         else:

=== modified file 'lib/lp/bugs/mail/commands.py'
--- lib/lp/bugs/mail/commands.py	2012-06-20 11:57:08 +0000
+++ lib/lp/bugs/mail/commands.py	2012-06-29 08:46:59 +0000
@@ -433,7 +433,7 @@
         duplicate_field = IBug['duplicateof'].bind(context)
         try:
             duplicate_field.validate(bug)
-        except ValidationError, error:
+        except ValidationError as error:
             raise EmailProcessingError(error.doc())
 
         context_snapshot = Snapshot(
@@ -592,7 +592,7 @@
                 stop_processing=True)
         try:
             bug_target = self.getBugTarget(path)
-        except BugTargetNotFound, error:
+        except BugTargetNotFound as error:
             raise EmailProcessingError(unicode(error), stop_processing=True)
         event = None
 

=== modified file 'lib/lp/bugs/mail/handler.py'
--- lib/lp/bugs/mail/handler.py	2012-06-20 08:15:51 +0000
+++ lib/lp/bugs/mail/handler.py	2012-06-29 08:46:59 +0000
@@ -302,7 +302,7 @@
                         bugtask, bugtask_event = command.execute(
                             bugtask, bugtask_event)
 
-                except EmailProcessingError, error:
+                except EmailProcessingError as error:
                     processing_errors.append((error, command))
                     if error.stop_processing:
                         commands = []
@@ -321,7 +321,7 @@
             self.notify_bug_event(bug_event)
             self.notify_bugtask_event(bugtask_event, bug_event)
 
-        except IncomingEmailError, error:
+        except IncomingEmailError as error:
             send_process_error_notification(
                 str(getUtility(ILaunchBag).user.preferredemail.email),
                 'Submit Request Failure',

=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py	2012-06-19 04:38:35 +0000
+++ lib/lp/bugs/model/bug.py	2012-06-29 08:46:59 +0000
@@ -1977,7 +1977,7 @@
                         change, empty_recipients, deferred=True)
 
             self.duplicateof = duplicate_of
-        except LaunchpadValidationError, validation_error:
+        except LaunchpadValidationError as validation_error:
             raise InvalidDuplicateValue(validation_error)
         if duplicate_of is not None:
             # Maybe confirm bug tasks, now that more people might be affected

=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py	2012-06-14 07:43:06 +0000
+++ lib/lp/bugs/model/bugtask.py	2012-06-29 08:46:59 +0000
@@ -381,7 +381,7 @@
             try:
                 target.distribution.guessPublishedSourcePackageName(
                     target.sourcepackagename.name)
-            except NotFoundError, e:
+            except NotFoundError as e:
                 raise IllegalTarget(e[0])
 
     if bug.information_type == InformationType.PROPRIETARY:

=== modified file 'lib/lp/bugs/model/bugwatch.py'
--- lib/lp/bugs/model/bugwatch.py	2012-02-23 23:37:16 +0000
+++ lib/lp/bugs/model/bugwatch.py	2012-06-29 08:46:59 +0000
@@ -432,7 +432,7 @@
         for url in matches:
             try:
                 bugtracker, remotebug = self.extractBugTrackerAndBug(str(url))
-            except NoBugTrackerFound, error:
+            except NoBugTrackerFound as error:
                 # We don't want to auto-create EMAILADDRESS bug trackers
                 # based on mailto: URIs in comments.
                 if error.bugtracker_type == BugTrackerType.EMAILADDRESS:

=== modified file 'lib/lp/bugs/scripts/bugimport.py'
--- lib/lp/bugs/scripts/bugimport.py	2012-06-13 21:40:11 +0000
+++ lib/lp/bugs/scripts/bugimport.py	2012-06-29 08:46:59 +0000
@@ -351,7 +351,7 @@
             try:
                 bugtracker, remotebug = bugwatchset.extractBugTrackerAndBug(
                     watchnode.get('href'))
-            except NoBugTrackerFound, exc:
+            except NoBugTrackerFound as exc:
                 self.logger.debug(
                     'Registering bug tracker for %s', exc.base_url)
                 bugtracker = getUtility(IBugTrackerSet).ensureBugTracker(

=== modified file 'lib/lp/bugs/scripts/bzremotecomponentfinder.py'
--- lib/lp/bugs/scripts/bzremotecomponentfinder.py	2012-02-24 01:25:58 +0000
+++ lib/lp/bugs/scripts/bzremotecomponentfinder.py	2012-06-29 08:46:59 +0000
@@ -150,7 +150,7 @@
             try:
                 self.logger.debug("...Fetching page")
                 page_text = bz_bugtracker.getPage()
-            except HTTPError, error:
+            except HTTPError as error:
                 self.logger.warning("Could not fetch %s: %s" % (
                     lp_bugtracker.baseurl, error))
                 continue

=== modified file 'lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py'
--- lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py	2012-06-29 08:46:59 +0000
@@ -89,7 +89,7 @@
                 if self.can_back_link:
                     error_status = BugWatchActivityStatus.BACKLINK_FAILED
                     self.linkLaunchpadBug()
-            except Exception, ex:
+            except Exception as ex:
                 error_message = str(ex)
                 log_message = (
                     "Failure updating bug %r on %s (local bug: %s)" %

=== modified file 'lib/lp/bugs/scripts/checkwatches/core.py'
--- lib/lp/bugs/scripts/checkwatches/core.py	2011-12-30 06:14:56 +0000
+++ lib/lp/bugs/scripts/checkwatches/core.py	2012-06-29 08:46:59 +0000
@@ -121,7 +121,7 @@
     """
     try:
         yield
-    except Exception, e:
+    except Exception as e:
         # We record the error against all the bugwatches that should
         # have been updated before re-raising it. We also update the
         # bug watches' lastchecked dates so that checkwatches
@@ -267,7 +267,7 @@
         except (KeyboardInterrupt, SystemExit):
             # We should never catch KeyboardInterrupt or SystemExit.
             raise
-        except Exception, error:
+        except Exception as error:
             # If something unexpected goes wrong, we log it and
             # continue: a failure shouldn't break the updating of
             # the other bug trackers.
@@ -426,7 +426,7 @@
             try:
                 trackers_and_watches = self._getExternalBugTrackersAndWatches(
                     bug_tracker, bug_watches_to_update)
-            except (UnknownBugTrackerTypeError, ProtocolError), error:
+            except (UnknownBugTrackerTypeError, ProtocolError) as error:
                 # We update all the bug watches to reflect the fact that
                 # this error occurred. We also update their last checked
                 # date to ensure that they don't get checked for another

=== modified file 'lib/lp/bugs/scripts/checkwatches/remotebugupdater.py'
--- lib/lp/bugs/scripts/checkwatches/remotebugupdater.py	2012-04-16 23:02:44 +0000
+++ lib/lp/bugs/scripts/checkwatches/remotebugupdater.py	2012-06-29 08:46:59 +0000
@@ -145,7 +145,7 @@
                         self.remote_bug))
                 new_malone_importance = self._convertRemoteImportance(
                     new_remote_importance)
-            except (InvalidBugId, BugNotFound, PrivateRemoteBug), ex:
+            except (InvalidBugId, BugNotFound, PrivateRemoteBug) as ex:
                 error = get_bugwatcherrortype_for_error(ex)
                 message = self.error_type_messages.get(
                     error, self.error_type_message_default)
@@ -170,7 +170,7 @@
                     bug_watch_updater.updateBugWatch(
                         new_remote_status, new_malone_status,
                         new_remote_importance, new_malone_importance)
-        except Exception, error:
+        except Exception as error:
             # Send the error to the log.
             oops_id = self.error(
                 "Failure updating bug %r on %s (local bugs: %s)." %
@@ -225,7 +225,7 @@
 
         try:
             launchpad_value = conversion_method(remote_value)
-        except UnknownRemoteValueError, e:
+        except UnknownRemoteValueError as e:
             # We log the warning, since we need to know about values
             # that we don't handle correctly.
             self.logger.info(

=== modified file 'lib/lp/bugs/scripts/debbugs.py'
--- lib/lp/bugs/scripts/debbugs.py	2010-08-20 20:31:18 +0000
+++ lib/lp/bugs/scripts/debbugs.py	2012-06-29 08:46:59 +0000
@@ -151,14 +151,14 @@
 
         try:
             fd = open(summary)
-        except IOError, e:
+        except IOError as e:
             if e.errno == 2:
                 raise SummaryMissing, summary
             raise
 
         try:
             message = email.message_from_file(fd)
-        except Exception, e:
+        except Exception as e:
             raise SummaryParseError, '%s: %s' % (summary, str(e))
 
         version = message['format-version']
@@ -192,7 +192,7 @@
 
         try:
             fd = open(report)
-        except IOError, e:
+        except IOError as e:
             if e.errno == 2:
                 raise ReportMissing, report
             raise
@@ -241,7 +241,7 @@
             if process.returncode != 0:
                 raise LogParseFailed(errors)
 
-        except IOError, e:
+        except IOError as e:
             if e.errno == 2:
                 raise LogMissing, log
             raise
@@ -268,7 +268,7 @@
     for bug in Database('/srv/debzilla.no-name-yet.com/debbugs'):
         try:
             print bug, bug.subject
-        except Exception, e:
+        except Exception as e:
             print >>sys.stderr, '%s: %s' % (e.__class__.__name__, str(e))
 
 

=== modified file 'lib/lp/bugs/scripts/sfremoteproductfinder.py'
--- lib/lp/bugs/scripts/sfremoteproductfinder.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/scripts/sfremoteproductfinder.py	2012-06-29 08:46:59 +0000
@@ -55,7 +55,7 @@
         # First, fetch the project page.
         try:
             soup = BeautifulSoup(self._getPage("projects/%s" % sf_project))
-        except HTTPError, error:
+        except HTTPError as error:
             self.logger.error(
                 "Error fetching project %s: %s" %
                 (sf_project, error))
@@ -75,7 +75,7 @@
         tracker_url = tracker_url.lstrip('/')
         try:
             soup = BeautifulSoup(self._getPage(tracker_url))
-        except HTTPError, error:
+        except HTTPError as error:
             self.logger.error(
                 "Error fetching project %s: %s" %
                 (sf_project, error))

=== modified file 'lib/lp/bugs/scripts/updateremoteproduct.py'
--- lib/lp/bugs/scripts/updateremoteproduct.py	2011-12-19 14:54:37 +0000
+++ lib/lp/bugs/scripts/updateremoteproduct.py	2012-06-29 08:46:59 +0000
@@ -85,7 +85,7 @@
             #     bug 334449 is fixed this part of the except should be
             #     removed.
             except (AssertionError, BugWatchUpdateError,
-                    BugWatchUpdateWarning), error:
+                    BugWatchUpdateWarning) as error:
                 self.logger.error(
                     "Unable to set remote_product for '%s': %s" %
                     (product.name, error))

=== modified file 'lib/lp/bugs/tests/test_bugwatch.py'
--- lib/lp/bugs/tests/test_bugwatch.py	2012-02-23 23:37:16 +0000
+++ lib/lp/bugs/tests/test_bugwatch.py	2012-06-29 08:46:59 +0000
@@ -112,7 +112,7 @@
         try:
             bugtracker, bug = self.bugwatch_set.extractBugTrackerAndBug(
                 self.bug_url)
-        except NoBugTrackerFound, error:
+        except NoBugTrackerFound as error:
             # The raised exception should contain enough information so
             # that we can register a new bug tracker.
             self.assertEqual(error.base_url, self.base_url)

=== modified file 'lib/lp/bugs/tests/test_duplicate_handling.py'
--- lib/lp/bugs/tests/test_duplicate_handling.py	2012-04-16 23:02:44 +0000
+++ lib/lp/bugs/tests/test_duplicate_handling.py	2012-06-29 08:46:59 +0000
@@ -48,7 +48,7 @@
     def assertDuplicateError(self, bug, duplicateof, msg):
         try:
             bug.markAsDuplicate(duplicateof)
-        except InvalidDuplicateValue, err:
+        except InvalidDuplicateValue as err:
             self.assertEqual(str(err), msg)
 
     def test_error_on_duplicate_to_duplicate(self):

=== modified file 'lib/lp/buildmaster/model/builder.py'
--- lib/lp/buildmaster/model/builder.py	2012-05-23 10:28:40 +0000
+++ lib/lp/buildmaster/model/builder.py	2012-06-29 08:46:59 +0000
@@ -372,7 +372,7 @@
         slave_build_id = status_sentence[ident_position[status]]
         try:
             builder.verifySlaveBuildCookie(slave_build_id)
-        except CorruptBuildCookie, reason:
+        except CorruptBuildCookie as reason:
             if status == 'BuilderStatus.WAITING':
                 d = builder.cleanSlave()
             else:

=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py	2012-06-22 05:52:17 +0000
+++ lib/lp/code/browser/branch.py	2012-06-29 08:46:59 +0000
@@ -1120,7 +1120,7 @@
                     self.addError(
                         "%s is not allowed to own branches in %s." % (
                         owner.displayname, self.context.target.displayname))
-                except BranchExists, e:
+                except BranchExists as e:
                     self._setBranchExists(e.existing_branch)
 
         # If the branch is a MIRRORED branch, then the url
@@ -1317,7 +1317,7 @@
                 return None
             else:
                 self.next_url = canonical_url(proposal)
-        except InvalidBranchMergeProposal, error:
+        except InvalidBranchMergeProposal as error:
             self.addError(str(error))
 
     def validate(self, data):
@@ -1373,7 +1373,7 @@
         except CodeImportAlreadyRunning:
             self.request.response.addNotification(
                 "The import is already running.")
-        except CodeImportAlreadyRequested, e:
+        except CodeImportAlreadyRequested as e:
             user = e.requesting_user
             adapter = queryAdapter(user, IPathAdapter, 'fmt')
             self.request.response.addNotification(

=== modified file 'lib/lp/code/browser/codeimport.py'
--- lib/lp/code/browser/codeimport.py	2012-02-28 01:22:50 +0000
+++ lib/lp/code/browser/codeimport.py	2012-06-29 08:46:59 +0000
@@ -426,7 +426,7 @@
         """Create the code_import, and subscribe the user to the branch."""
         try:
             code_import = self._create_import(data, None)
-        except BranchExists, e:
+        except BranchExists as e:
             self._setBranchExists(e.existing_branch)
             return
 

=== modified file 'lib/lp/code/browser/codereviewvote.py'
--- lib/lp/code/browser/codereviewvote.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/browser/codereviewvote.py	2012-06-29 08:46:59 +0000
@@ -53,5 +53,5 @@
         if reviewer is not None:
             try:
                 self.context.validateReasignReview(reviewer)
-            except (ReviewNotPending, UserHasExistingReview), e:
+            except (ReviewNotPending, UserHasExistingReview) as e:
                 self.addError(str(e))

=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
--- lib/lp/code/browser/sourcepackagerecipe.py	2012-06-15 16:23:50 +0000
+++ lib/lp/code/browser/sourcepackagerecipe.py	2012-06-29 08:46:59 +0000
@@ -434,7 +434,7 @@
                 build = self.context.requestBuild(
                     data['archive'], self.user, distroseries, manual=True)
                 builds.append(build)
-            except BuildAlreadyPending, e:
+            except BuildAlreadyPending as e:
                 existing_message = informational.get("already_pending")
                 if existing_message:
                     new_message = existing_message[:-1] + (
@@ -636,7 +636,7 @@
         try:
             parser = RecipeParser(data['recipe_text'])
             parser.parse()
-        except RecipeParseError, error:
+        except RecipeParseError as error:
             self.setFieldError('recipe_text', str(error))
 
     def error_handler(self, callable, *args, **kwargs):
@@ -646,15 +646,15 @@
             self.setFieldError(
                 'recipe_text',
                 'The recipe format version specified is not available.')
-        except ForbiddenInstructionError, e:
+        except ForbiddenInstructionError as e:
             self.setFieldError(
                 'recipe_text',
                 'The bzr-builder instruction "%s" is not permitted '
                 'here.' % e.instruction_name)
-        except NoSuchBranch, e:
+        except NoSuchBranch as e:
             self.setFieldError(
                 'recipe_text', '%s is not a branch on Launchpad.' % e.name)
-        except PrivateBranchRecipe, e:
+        except PrivateBranchRecipe as e:
             self.setFieldError('recipe_text', str(e))
         raise ErrorHandled()
 

=== modified file 'lib/lp/code/interfaces/codeimport.py'
--- lib/lp/code/interfaces/codeimport.py	2012-02-28 01:22:50 +0000
+++ lib/lp/code/interfaces/codeimport.py	2012-06-29 08:46:59 +0000
@@ -54,7 +54,7 @@
 def validate_cvs_root(cvsroot):
     try:
         root = CVSRoot(cvsroot)
-    except CvsRootError, e:
+    except CvsRootError as e:
         raise LaunchpadValidationError(e)
     if root.method == 'local':
         raise LaunchpadValidationError('Local CVS roots are not allowed.')

=== modified file 'lib/lp/code/mail/codehandler.py'
--- lib/lp/code/mail/codehandler.py	2012-06-20 08:15:51 +0000
+++ lib/lp/code/mail/codehandler.py	2012-06-29 08:46:59 +0000
@@ -266,7 +266,7 @@
         for command in commands:
             try:
                 command.execute(context)
-            except EmailProcessingError, error:
+            except EmailProcessingError as error:
                 processing_errors.append((error, command))
 
         if len(processing_errors) > 0:
@@ -315,7 +315,7 @@
             merge_proposal.createCommentFromMessage(
                 message, context.vote, context.vote_tags, mail)
 
-        except IncomingEmailError, error:
+        except IncomingEmailError as error:
             send_process_error_notification(
                 str(user.preferredemail.email),
                 'Submit Request Failure',

=== modified file 'lib/lp/code/model/sourcepackagerecipebuild.py'
--- lib/lp/code/model/sourcepackagerecipebuild.py	2012-04-24 06:37:38 +0000
+++ lib/lp/code/model/sourcepackagerecipebuild.py	2012-06-29 08:46:59 +0000
@@ -225,7 +225,7 @@
                     logger.debug(
                         ' - build already pending for %s', series_name)
                     continue
-                except CannotUploadToArchive, e:
+                except CannotUploadToArchive as e:
                     # This will catch all PPA related issues -
                     # disabled, security, wrong pocket etc
                     logger.debug(

=== modified file 'lib/lp/code/model/tests/test_codeimportjob.py'
--- lib/lp/code/model/tests/test_codeimportjob.py	2011-12-30 06:14:56 +0000
+++ lib/lp/code/model/tests/test_codeimportjob.py	2012-06-29 08:46:59 +0000
@@ -310,7 +310,7 @@
         """
         try:
             callable_obj(*args, **kwargs)
-        except AssertionError, exception:
+        except AssertionError as exception:
             self.assertEqual(str(exception), message)
         else:
             self.fail("AssertionError was not raised")

=== modified file 'lib/lp/code/xmlrpc/branch.py'
--- lib/lp/code/xmlrpc/branch.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/xmlrpc/branch.py	2012-06-29 08:46:59 +0000
@@ -127,7 +127,7 @@
         try:
             unicode_branch_url = branch_url.decode('utf-8')
             IBranch['url'].validate(unicode_branch_url)
-        except LaunchpadValidationError, exc:
+        except LaunchpadValidationError as exc:
             return faults.InvalidBranchUrl(branch_url, exc)
 
         # We want it to be None in the database, not ''.
@@ -154,9 +154,9 @@
                 branch.requestMirror()
         except BranchCreationForbidden:
             return faults.BranchCreationForbidden(product.displayname)
-        except BranchCreationException, err:
+        except BranchCreationException as err:
             return faults.BranchNameInUse(err)
-        except LaunchpadValidationError, err:
+        except LaunchpadValidationError as err:
             return faults.InvalidBranchName(err)
 
         return canonical_url(branch)
@@ -303,24 +303,24 @@
         # and thus error prone. Alternatives are directly raising faults from
         # the model code(blech) or some automated way of reraising as faults
         # or using a narrower range of faults (e.g. only one "NoSuch" fault).
-        except InvalidProductName, e:
+        except InvalidProductName as e:
             raise faults.InvalidProductIdentifier(urlutils.escape(e.name))
-        except NoSuchProductSeries, e:
+        except NoSuchProductSeries as e:
             raise faults.NoSuchProductSeries(
                 urlutils.escape(e.name), e.product)
-        except NoSuchPerson, e:
+        except NoSuchPerson as e:
             raise faults.NoSuchPersonWithName(urlutils.escape(e.name))
-        except NoSuchProduct, e:
+        except NoSuchProduct as e:
             raise faults.NoSuchProduct(urlutils.escape(e.name))
-        except NoSuchDistroSeries, e:
+        except NoSuchDistroSeries as e:
             raise faults.NoSuchDistroSeries(urlutils.escape(e.name))
-        except NoSuchSourcePackageName, e:
+        except NoSuchSourcePackageName as e:
             raise faults.NoSuchSourcePackageName(urlutils.escape(e.name))
-        except NoLinkedBranch, e:
+        except NoLinkedBranch as e:
             raise faults.NoLinkedBranch(e.component)
-        except CannotHaveLinkedBranch, e:
+        except CannotHaveLinkedBranch as e:
             raise faults.CannotHaveLinkedBranch(e.component)
-        except InvalidNamespace, e:
+        except InvalidNamespace as e:
             raise faults.InvalidBranchUniqueName(urlutils.escape(e.name))
         # Reverse engineer the actual lp_path that is used, so we need to
         # remove any suffix that may be there from the strip_path.

=== modified file 'lib/lp/code/xmlrpc/codehosting.py'
--- lib/lp/code/xmlrpc/codehosting.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/xmlrpc/codehosting.py	2012-06-29 08:46:59 +0000
@@ -219,10 +219,10 @@
             except InvalidNamespace:
                 return faults.PermissionDenied(
                     "Cannot create branch at '%s'" % branch_path)
-            except NoSuchPerson, e:
+            except NoSuchPerson as e:
                 return faults.NotFound(
                     "User/team '%s' does not exist." % e.name)
-            except NoSuchProduct, e:
+            except NoSuchProduct as e:
                 return faults.NotFound(
                     "Project '%s' does not exist." % e.name)
             except NoSuchSourcePackageName as e:
@@ -231,17 +231,17 @@
                 except InvalidName:
                     return faults.InvalidSourcePackageName(e.name)
                 return self.createBranch(login_id, branch_path)
-            except NameLookupFailed, e:
+            except NameLookupFailed as e:
                 return faults.NotFound(str(e))
             try:
                 branch = namespace.createBranch(
                     BranchType.HOSTED, branch_name, requester)
-            except LaunchpadValidationError, e:
+            except LaunchpadValidationError as e:
                 msg = e.args[0]
                 if isinstance(msg, unicode):
                     msg = msg.encode('utf-8')
                 return faults.PermissionDenied(msg)
-            except BranchCreationException, e:
+            except BranchCreationException as e:
                 return faults.PermissionDenied(str(e))
 
             if link_func:

=== modified file 'lib/lp/codehosting/codeimport/tests/helpers.py'
--- lib/lp/codehosting/codeimport/tests/helpers.py	2009-06-25 04:06:00 +0000
+++ lib/lp/codehosting/codeimport/tests/helpers.py	2012-06-29 08:46:59 +0000
@@ -31,7 +31,7 @@
         self.observer.called(self.name, args, kwargs)
         try:
             value = self.callable(*args, **kwargs)
-        except Exception, exc:
+        except Exception as exc:
             self.observer.raised(self.name, exc)
             raise
         else:

=== modified file 'lib/lp/codehosting/codeimport/tests/servers.py'
--- lib/lp/codehosting/codeimport/tests/servers.py	2011-09-01 21:00:42 +0000
+++ lib/lp/codehosting/codeimport/tests/servers.py	2012-06-29 08:46:59 +0000
@@ -127,7 +127,7 @@
             for i in range(10):
                 try:
                     self._get_ra(self.get_url())
-                except OSError, e:
+                except OSError as e:
                     if e.errno == errno.ECONNREFUSED:
                         time.sleep(delay)
                         delay *= 1.5

=== modified file 'lib/lp/codehosting/codeimport/worker.py'
--- lib/lp/codehosting/codeimport/worker.py	2012-02-27 23:59:14 +0000
+++ lib/lp/codehosting/codeimport/worker.py	2012-06-29 08:46:59 +0000
@@ -731,10 +731,10 @@
             except NotBranchError:
                 self._logger.info("No branch found at remote location.")
                 return CodeImportWorkerExitCode.FAILURE_INVALID
-            except BadUrl, e:
+            except BadUrl as e:
                 self._logger.info("Invalid URL: %s" % e)
                 return CodeImportWorkerExitCode.FAILURE_FORBIDDEN
-            except ConnectionError, e:
+            except ConnectionError as e:
                 self._logger.info("Unable to open remote branch: %s" % e)
                 return CodeImportWorkerExitCode.FAILURE_INVALID
             try:
@@ -751,7 +751,7 @@
                         result = CodeImportWorkerExitCode.SUCCESS_NOCHANGE
                 else:
                     result = CodeImportWorkerExitCode.SUCCESS_PARTIAL
-            except Exception, e:
+            except Exception as e:
                 if e.__class__ in self.unsupported_feature_exceptions:
                     self._logger.info(
                         "Unable to import branch because of limitations in "

=== modified file 'lib/lp/codehosting/inmemory.py'
--- lib/lp/codehosting/inmemory.py	2012-06-01 02:26:43 +0000
+++ lib/lp/codehosting/inmemory.py	2012-06-29 08:46:59 +0000
@@ -701,9 +701,9 @@
         registrant = self._person_set.get(requester_id)
         try:
             return self._createBranch(registrant, escaped_path)
-        except LaunchpadFault, e:
+        except LaunchpadFault as e:
             return e
-        except LaunchpadValidationError, e:
+        except LaunchpadValidationError as e:
             msg = e.args[0]
             if isinstance(msg, unicode):
                 msg = msg.encode('utf-8')

=== modified file 'lib/lp/codehosting/puller/__init__.py'
--- lib/lp/codehosting/puller/__init__.py	2010-08-20 20:31:18 +0000
+++ lib/lp/codehosting/puller/__init__.py	2012-06-29 08:46:59 +0000
@@ -25,7 +25,7 @@
     """Mirror all current branches that need to be mirrored."""
     try:
         manager.lock()
-    except LockError, exception:
+    except LockError as exception:
         logger.info('Could not acquire lock: %s', exception)
         return defer.succeed(0)
 

=== modified file 'lib/lp/codehosting/puller/worker.py'
--- lib/lp/codehosting/puller/worker.py	2012-04-16 23:02:44 +0000
+++ lib/lp/codehosting/puller/worker.py	2012-06-29 08:46:59 +0000
@@ -384,7 +384,7 @@
         # add further encountered errors from the production runs here
         # ------ HERE ---------
         #
-        except urllib2.HTTPError, e:
+        except urllib2.HTTPError as e:
             msg = str(e)
             if int(e.code) == httplib.UNAUTHORIZED:
                 # Maybe this will be caught in bzrlib one day, and then we'll
@@ -393,19 +393,19 @@
                 msg = "Authentication required."
             self._mirrorFailed(msg)
 
-        except socket.error, e:
+        except socket.error as e:
             msg = 'A socket error occurred: %s' % str(e)
             self._mirrorFailed(msg)
 
-        except errors.UnsupportedFormatError, e:
+        except errors.UnsupportedFormatError as e:
             msg = ("Launchpad does not support branches from before "
                    "bzr 0.7. Please upgrade the branch using bzr upgrade.")
             self._mirrorFailed(msg)
 
-        except errors.UnknownFormatError, e:
+        except errors.UnknownFormatError as e:
             self._mirrorFailed(e)
 
-        except (errors.ParamikoNotPresent, BadUrlSsh), e:
+        except (errors.ParamikoNotPresent, BadUrlSsh) as e:
             msg = ("Launchpad cannot mirror branches from SFTP and SSH URLs."
                    " Please register a HTTP location for this branch.")
             self._mirrorFailed(msg)
@@ -414,11 +414,11 @@
             msg = "Launchpad does not mirror branches from Launchpad."
             self._mirrorFailed(msg)
 
-        except BadUrlScheme, e:
+        except BadUrlScheme as e:
             msg = "Launchpad does not mirror %s:// URLs." % e.scheme
             self._mirrorFailed(msg)
 
-        except errors.NotBranchError, e:
+        except errors.NotBranchError as e:
             hosted_branch_error = errors.NotBranchError(
                 "lp:%s" % self.unique_name)
             message_by_type = {
@@ -428,19 +428,19 @@
             msg = message_by_type.get(self.branch_type, str(e))
             self._mirrorFailed(msg)
 
-        except BranchReferenceForbidden, e:
+        except BranchReferenceForbidden as e:
             msg = ("Branch references are not allowed for branches of type "
                    "%s." % (self.branch_type.title,))
             self._mirrorFailed(msg)
 
-        except BranchLoopError, e:
+        except BranchLoopError as e:
             msg = "Circular branch reference."
             self._mirrorFailed(msg)
 
-        except errors.BzrError, e:
+        except errors.BzrError as e:
             self._mirrorFailed(e)
 
-        except InvalidURIError, e:
+        except InvalidURIError as e:
             self._mirrorFailed(e)
 
         except (KeyboardInterrupt, SystemExit):

=== modified file 'lib/lp/codehosting/safe_open.py'
--- lib/lp/codehosting/safe_open.py	2012-01-06 11:08:30 +0000
+++ lib/lp/codehosting/safe_open.py	2012-06-29 08:46:59 +0000
@@ -317,7 +317,7 @@
                 prober = prober_kls()
                 try:
                     return transport, prober.probe_transport(transport)
-                except errors.NotBranchError, e:
+                except errors.NotBranchError as e:
                     last_error = e
             else:
                 raise last_error

=== modified file 'lib/lp/codehosting/scripts/modifiedbranches.py'
--- lib/lp/codehosting/scripts/modifiedbranches.py	2012-01-01 02:58:52 +0000
+++ lib/lp/codehosting/scripts/modifiedbranches.py	2012-06-29 08:46:59 +0000
@@ -80,7 +80,7 @@
             try:
                 parsed_time = strptime(self.options.since, '%Y-%m-%d')
                 last_modified = datetime(*(parsed_time[:3]))
-            except ValueError, e:
+            except ValueError as e:
                 raise LaunchpadScriptFailure(str(e))
         else:
             raise LaunchpadScriptFailure(

=== modified file 'lib/lp/codehosting/sftp.py'
--- lib/lp/codehosting/sftp.py	2012-01-01 02:58:52 +0000
+++ lib/lp/codehosting/sftp.py	2012-06-29 08:46:59 +0000
@@ -68,7 +68,7 @@
         osutils.check_legal_path(abspath)
         try:
             chunk_file = os.open(abspath, os.O_CREAT | os.O_WRONLY)
-        except OSError, e:
+        except OSError as e:
             if e.errno != errno.EISDIR:
                 raise
             raise FileIsADirectory(name)

=== modified file 'lib/lp/codehosting/sshserver/session.py'
--- lib/lp/codehosting/sshserver/session.py	2012-04-16 23:02:44 +0000
+++ lib/lp/codehosting/sshserver/session.py	2012-06-29 08:46:59 +0000
@@ -121,7 +121,7 @@
             client_sock.sendall(message)
             # We define the requests to be no bigger than 1kB. (For now)
             response = client_sock.recv(1024)
-        except socket.error, e:
+        except socket.error as e:
             # TODO: What exceptions should be raised?
             #       Raising the raw exception seems to kill the twisted reactor
             #       Note that if the connection is refused, we *could* just
@@ -346,7 +346,7 @@
         """
         try:
             executable, arguments = self.getCommandToRun(command)
-        except ForbiddenCommand, e:
+        except ForbiddenCommand as e:
             self.errorWithMessage(protocol, str(e) + '\r\n')
             return
         log.msg('Running: %r, %r' % (executable, arguments))

=== modified file 'lib/lp/codehosting/vfs/transport.py'
--- lib/lp/codehosting/vfs/transport.py	2011-07-18 20:46:27 +0000
+++ lib/lp/codehosting/vfs/transport.py	2012-06-29 08:46:59 +0000
@@ -135,7 +135,7 @@
             method = getattr(transport, method_name)
             try:
                 return method(path, *args, **kwargs)
-            except BaseException, e:
+            except BaseException as e:
                 # It's much cheaper to explicitly construct a Failure than to
                 # let Deferred build automatically, because the automatic one
                 # will capture the traceback and perform an expensive

=== modified file 'lib/lp/hardwaredb/scripts/hwdbsubmissions.py'
--- lib/lp/hardwaredb/scripts/hwdbsubmissions.py	2011-12-30 09:16:36 +0000
+++ lib/lp/hardwaredb/scripts/hwdbsubmissions.py	2012-06-29 08:46:59 +0000
@@ -219,7 +219,7 @@
         submission = self.fixFrequentErrors(submission)
         try:
             tree = etree.parse(StringIO(submission), parser=self.doc_parser)
-        except SyntaxError, error_value:
+        except SyntaxError as error_value:
             self._logError(error_value, submission_key)
             return None
 
@@ -988,7 +988,7 @@
                 if result is None:
                     return None
                 submission_data[node.tag] = result
-        except ValueError, value:
+        except ValueError as value:
             self._logError(value, self.submission_key)
             return None
         return submission_data
@@ -1480,7 +1480,7 @@
                 udi_device_map = self.getUDIDeviceMap(
                     parsed_data['hardware']['hal']['devices'])
                 udi_children = self.getUDIChildren(udi_device_map)
-            except ValueError, value:
+            except ValueError as value:
                 self._logError(value, self.submission_key)
                 return False
 

=== modified file 'lib/lp/poppy/hooks.py'
--- lib/lp/poppy/hooks.py	2011-02-23 14:51:30 +0000
+++ lib/lp/poppy/hooks.py	2012-06-29 08:46:59 +0000
@@ -158,7 +158,7 @@
         #        self.logger.debug("Accepting login for %s" % user)
         #        self.clients[fsroot]["distro"] = user
         #        return True
-        #except object, e:
+        #except object as e:
         #    print e
         #return False
 

=== modified file 'lib/lp/poppy/twistedsftp.py'
--- lib/lp/poppy/twistedsftp.py	2011-11-30 15:05:14 +0000
+++ lib/lp/poppy/twistedsftp.py	2012-06-29 08:46:59 +0000
@@ -129,7 +129,7 @@
         try:
             chunk_file = os.open(
                 self.filename, os.O_CREAT | os.O_WRONLY, 0644)
-        except OSError, e:
+        except OSError as e:
             if e.errno != errno.EISDIR:
                 raise
             raise FileIsADirectory(self.filename)

=== modified file 'lib/lp/registry/browser/nameblacklist.py'
--- lib/lp/registry/browser/nameblacklist.py	2012-01-05 20:11:40 +0000
+++ lib/lp/registry/browser/nameblacklist.py	2012-06-29 08:46:59 +0000
@@ -62,7 +62,7 @@
                     self.setFieldError(
                         'regexp',
                         'This regular expression already exists.')
-        except re.error, e:
+        except re.error as e:
             self.setFieldError(
                 'regexp',
                 'Invalid regular expression: %s' % e)

=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py	2012-06-14 05:18:22 +0000
+++ lib/lp/registry/browser/person.py	2012-06-29 08:46:59 +0000
@@ -1462,7 +1462,7 @@
             self.request.response.addInfoNotification(
                 _("Voucher redeemed successfully"))
             self.removeRedeemableVoucher(voucher)
-        except SalesforceVoucherProxyException, error:
+        except SalesforceVoucherProxyException as error:
             self.addError(
                 _("The voucher could not be redeemed at this time."))
             # Log an OOPS report without raising an error.
@@ -4326,7 +4326,7 @@
         try:
             send_direct_contact_email(
                 sender_email, self.recipients, subject, message)
-        except QuotaReachedError, error:
+        except QuotaReachedError as error:
             fmt_date = DateTimeFormatterAPI(self.next_try)
             self.request.response.addErrorNotification(
                 _('Your message was not sent because you have exceeded your '

=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py	2012-06-19 18:29:44 +0000
+++ lib/lp/registry/browser/productseries.py	2012-06-29 08:46:59 +0000
@@ -1091,7 +1091,7 @@
                         url=url,
                         cvs_root=cvs_root,
                         cvs_module=cvs_module)
-                except BranchExists, e:
+                except BranchExists as e:
                     self._setBranchExists(e.existing_branch,
                                           'branch_name')
                     self.errors_in_action = True
@@ -1123,7 +1123,7 @@
             self.addError(
                 "You are not allowed to create branches in %s." %
                 self.context.displayname)
-        except BranchExists, e:
+        except BranchExists as e:
             self._setBranchExists(e.existing_branch, 'branch_name')
         if branch is None:
             self.errors_in_action = True

=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py	2012-04-20 05:00:49 +0000
+++ lib/lp/registry/browser/team.py	2012-06-29 08:46:59 +0000
@@ -354,7 +354,7 @@
                 self.context.transitionVisibility(visibility, self.user)
                 del data['visibility']
             self.updateContextFromData(data)
-        except ImmutableVisibilityError, error:
+        except ImmutableVisibilityError as error:
             self.request.response.addErrorNotification(str(error))
             # Abort must be called or changes to fields before the one causing
             # the error will be committed.  If we have a database validation
@@ -512,7 +512,7 @@
             if email is None or email.person != self.context:
                 try:
                     validate_new_team_email(data['contact_address'])
-                except LaunchpadValidationError, error:
+                except LaunchpadValidationError as error:
                     # We need to wrap this in structured, so that the
                     # markup is preserved.  Note that this puts the
                     # responsibility for security on the exception thrower.
@@ -1703,7 +1703,7 @@
             return (len(self.super_teams) > 0
                     or (self.context.open_membership_invitations
                         and check_permission('launchpad.Edit', self.context)))
-        except AttributeError, e:
+        except AttributeError as e:
             raise AssertionError(e)
 
     @property

=== modified file 'lib/lp/registry/browser/teammembership.py'
--- lib/lp/registry/browser/teammembership.py	2012-01-03 22:28:10 +0000
+++ lib/lp/registry/browser/teammembership.py	2012-06-29 08:46:59 +0000
@@ -278,7 +278,7 @@
             else:
                 try:
                     expires = self._getExpirationDate()
-                except ValueError, err:
+                except ValueError as err:
                     self.errormessage = (
                         'Invalid expiration: %s' % err)
                     return False
@@ -304,7 +304,7 @@
         expires = None
         try:
             expires = self.expiration_widget.getInputValue()
-        except InputErrors, value:
+        except InputErrors as value:
             # Handle conversion errors. We have to do this explicitly here
             # because we are not using the full form machinery which would
             # put the relevant error message into the field error. We are

=== modified file 'lib/lp/registry/interfaces/distroseries.py'
--- lib/lp/registry/interfaces/distroseries.py	2012-06-19 03:26:57 +0000
+++ lib/lp/registry/interfaces/distroseries.py	2012-06-29 08:46:59 +0000
@@ -171,7 +171,7 @@
             # have stricter version rules than the schema. The version must
             # be a debversion.
             Version(version)
-        except VersionError, error:
+        except VersionError as error:
             raise LaunchpadValidationError(
                 "'%s': %s" % (version, error))
 

=== modified file 'lib/lp/registry/model/codeofconduct.py'
--- lib/lp/registry/model/codeofconduct.py	2012-01-06 11:08:30 +0000
+++ lib/lp/registry/model/codeofconduct.py	2012-06-29 08:46:59 +0000
@@ -268,7 +268,7 @@
 
         try:
             sig = gpghandler.getVerifiedSignature(sane_signedcode)
-        except GPGVerificationError, e:
+        except GPGVerificationError as e:
             return str(e)
 
         if not sig.fingerprint:

=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py	2012-06-19 03:26:57 +0000
+++ lib/lp/registry/model/distroseries.py	2012-06-29 08:46:59 +0000
@@ -1632,7 +1632,7 @@
             rebuild, overlays, overlay_pockets, overlay_components)
         try:
             initialize_series.check()
-        except InitializationError, e:
+        except InitializationError as e:
             raise DerivationError(e)
         getUtility(IInitializeDistroSeriesJobSource).create(
             self, parents, architectures, archindep_archtag, packagesets,

=== modified file 'lib/lp/registry/scripts/distributionmirror_prober.py'
--- lib/lp/registry/scripts/distributionmirror_prober.py	2012-01-01 02:58:52 +0000
+++ lib/lp/registry/scripts/distributionmirror_prober.py	2012-06-29 08:46:59 +0000
@@ -335,11 +335,11 @@
             # XXX Guilherme Salgado 2007-04-23 bug=109223:
             # We can't assume url to be absolute here.
             self.setURL(url)
-        except (UnknownURLScheme,), e:
+        except (UnknownURLScheme,) as e:
             # Since we've got the UnknownURLScheme after a redirect, we need
             # to raise it in a form that can be ignored in the layer above.
             self.failed(UnknownURLSchemeAfterRedirect(url))
-        except (InfiniteLoopDetected,), e:
+        except (InfiniteLoopDetected,) as e:
             self.failed(e)
 
         else:
@@ -619,7 +619,7 @@
     url = config.distributionmirrorprober.cdimage_file_list_url
     try:
         return urllib2.urlopen(_build_request_for_cdimage_file_list(url))
-    except urllib2.URLError, e:
+    except urllib2.URLError as e:
         raise UnableToFetchCDImageFileList(
             'Unable to fetch %s: %s' % (url, e))
 
@@ -715,7 +715,7 @@
     mirror.deleteAllMirrorCDImageSeries()
     try:
         cdimage_paths = get_expected_cdimage_paths()
-    except UnableToFetchCDImageFileList, e:
+    except UnableToFetchCDImageFileList as e:
         logger.error(e)
         return
 

=== modified file 'lib/lp/registry/scripts/mlistimport.py'
--- lib/lp/registry/scripts/mlistimport.py	2012-06-13 21:14:17 +0000
+++ lib/lp/registry/scripts/mlistimport.py	2012-06-29 08:46:59 +0000
@@ -85,7 +85,7 @@
                                  may_subscribe_to_list=False)
             try:
                 self.mailing_list.subscribe(person, email)
-            except CannotSubscribe, error:
+            except CannotSubscribe as error:
                 self.log.error('%s', error)
             # It's okay to str()-ify these because addresses and person names
             # are guaranteed to be in the ASCII range.

=== modified file 'lib/lp/registry/scripts/productreleasefinder/walker.py'
--- lib/lp/registry/scripts/productreleasefinder/walker.py	2012-04-16 23:02:44 +0000
+++ lib/lp/registry/scripts/productreleasefinder/walker.py	2012-06-29 08:46:59 +0000
@@ -125,7 +125,7 @@
         """
         try:
             self.open()
-        except (IOError, socket.error), e:
+        except (IOError, socket.error) as e:
             self.log.info("Could not connect to %s" % self.base)
             self.log.info("Failure: %s" % e)
             return
@@ -341,10 +341,10 @@
         try:
             self.request("HEAD", path)
             return False
-        except urllib2.HTTPError, exc:
+        except urllib2.HTTPError as exc:
             if exc.code != 301:
                 return False
-        except (IOError, socket.error), exc:
+        except (IOError, socket.error) as exc:
             # Raise HTTPWalkerError for other IO or socket errors.
             raise HTTPWalkerError(str(exc))
 
@@ -376,7 +376,7 @@
                 soup = BeautifulSoup(response.read())
             finally:
                 response.close()
-        except (IOError, socket.error), exc:
+        except (IOError, socket.error) as exc:
             raise HTTPWalkerError(str(exc))
 
         base = URI(self.base).resolve(dirname)

=== modified file 'lib/lp/registry/tests/test_distributionmirror_prober.py'
--- lib/lp/registry/tests/test_distributionmirror_prober.py	2012-04-17 17:02:23 +0000
+++ lib/lp/registry/tests/test_distributionmirror_prober.py	2012-06-29 08:46:59 +0000
@@ -751,17 +751,17 @@
         try:
             callbacks.deleteMirrorSeries(
                 Failure(ProberTimeout('http://localhost/', 5)))
-        except Exception, e:
+        except Exception as e:
             self.fail("A timeout shouldn't be propagated. Got %s" % e)
         try:
             callbacks.deleteMirrorSeries(
                 Failure(BadResponseCode(str(httplib.INTERNAL_SERVER_ERROR))))
-        except Exception, e:
+        except Exception as e:
             self.fail(
                 "A bad response code shouldn't be propagated. Got %s" % e)
         try:
             callbacks.deleteMirrorSeries(Failure(ConnectionSkipped()))
-        except Exception, e:
+        except Exception as e:
             self.fail("A ConnectionSkipped exception shouldn't be "
                       "propagated. Got %s" % e)
 

=== modified file 'lib/lp/registry/tests/test_mlists.py'
--- lib/lp/registry/tests/test_mlists.py	2012-01-04 06:52:11 +0000
+++ lib/lp/registry/tests/test_mlists.py	2012-06-29 08:46:59 +0000
@@ -63,7 +63,7 @@
     def tearDown(self):
         try:
             os.remove(self.filename)
-        except OSError, error:
+        except OSError as error:
             if error.errno != errno.ENOENT:
                 raise
 

=== modified file 'lib/lp/registry/tests/test_packaging.py'
--- lib/lp/registry/tests/test_packaging.py	2012-01-01 02:58:52 +0000
+++ lib/lp/registry/tests/test_packaging.py	2012-06-29 08:46:59 +0000
@@ -273,7 +273,7 @@
                 productseries=firefox_trunk,
                 sourcepackagename=firefox_name,
                 distroseries=ubuntu_hoary)
-        except AssertionError, exception:
+        except AssertionError as exception:
             self.assertEqual(
                 str(exception),
                 "Tried to delete non-existent Packaging: "

=== modified file 'lib/lp/registry/tests/test_person.py'
--- lib/lp/registry/tests/test_person.py	2012-05-14 11:19:45 +0000
+++ lib/lp/registry/tests/test_person.py	2012-06-29 08:46:59 +0000
@@ -706,7 +706,7 @@
         self.otherteam.visibility = PersonVisibility.PRIVATE
         try:
             self.otherteam.visibility = PersonVisibility.PUBLIC
-        except ImmutableVisibilityError, exc:
+        except ImmutableVisibilityError as exc:
             self.assertEqual(
                 str(exc),
                 'A private team cannot change visibility.')

=== modified file 'lib/lp/registry/tests/test_project_milestone.py'
--- lib/lp/registry/tests/test_project_milestone.py	2012-01-01 02:58:52 +0000
+++ lib/lp/registry/tests/test_project_milestone.py	2012-06-29 08:46:59 +0000
@@ -330,7 +330,7 @@
             milestone.createProductRelease, 1, now)
         try:
             milestone.createProductRelease(1, now)
-        except MultipleProductReleases, e:
+        except MultipleProductReleases as e:
             self.assert_(
                 str(e), 'A milestone can only have one ProductRelease.')
 

=== modified file 'lib/lp/registry/tests/test_xmlrpc.py'
--- lib/lp/registry/tests/test_xmlrpc.py	2012-02-14 09:28:26 +0000
+++ lib/lp/registry/tests/test_xmlrpc.py	2012-06-29 08:46:59 +0000
@@ -100,7 +100,7 @@
         try:
             self.rpc_proxy.getOrCreateSoftwareCenterCustomer(
                 openid_identifier, 'a@xxxxx', 'Joe Blogs')
-        except xmlrpclib.Fault, e:
+        except xmlrpclib.Fault as e:
             fault_raised = True
             self.assertEqual(370, e.faultCode)
             self.assertIn(openid_identifier, e.faultString)
@@ -116,7 +116,7 @@
         try:
             self.rpc_proxy.getOrCreateSoftwareCenterCustomer(
                 'foo', 'a@xxxxx', 'Joe Blogs')
-        except xmlrpclib.Fault, e:
+        except xmlrpclib.Fault as e:
             fault_raised = True
             self.assertEqual(400, e.faultCode)
             self.assertIn('a@xxxxx', e.faultString)

=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2012-06-22 05:36:22 +0000
+++ lib/lp/scripts/garbo.py	2012-06-29 08:46:59 +0000
@@ -1078,7 +1078,7 @@
         for spec in self.getNextBatch(chunk_size):
             try:
                 work_items = extractWorkItemsFromWhiteboard(spec)
-            except Exception, e:
+            except Exception as e:
                 self.log.info(
                     "Failed to parse whiteboard of %s: %s" % (
                         spec, unicode(e)))

=== modified file 'lib/lp/scripts/runlaunchpad.py'
--- lib/lp/scripts/runlaunchpad.py	2012-01-13 14:20:49 +0000
+++ lib/lp/scripts/runlaunchpad.py	2012-06-29 08:46:59 +0000
@@ -449,7 +449,7 @@
                     signal.pause()
                 except KeyboardInterrupt:
                     pass
-    except Exception, e:
+    except Exception as e:
         print >> sys.stderr, "stopping services on exception %r" % e
         for service in services:
             print >> sys.stderr, service, "fixture details:"

=== modified file 'lib/lp/scripts/utilities/killservice.py'
--- lib/lp/scripts/utilities/killservice.py	2012-04-16 23:02:44 +0000
+++ lib/lp/scripts/utilities/killservice.py	2012-06-29 08:46:59 +0000
@@ -54,7 +54,7 @@
         log.debug("PID file is %s", pidfile_path(service))
         try:
             pid = get_pid(service)
-        except ValueError, error:
+        except ValueError as error:
             log.error(error)
             continue
         if pid is not None:
@@ -62,7 +62,7 @@
             try:
                 os.kill(pid, SIGTERM)
                 pids.append((service, pid))
-            except OSError, x:
+            except OSError as x:
                 log.error(
                     "Unable to SIGTERM %s (%d) - %s",
                     service, pid, x.strerror)
@@ -79,7 +79,7 @@
             "SIGTERM failed to kill %s (%d). Trying SIGKILL", service, pid)
         try:
             os.kill(pid, SIGKILL)
-        except OSError, x:
+        except OSError as x:
             log.error(
                 "Unable to SIGKILL %s (%d) - %s", service, pid, x.strerror)
 
@@ -106,7 +106,7 @@
     """True if the given process exists."""
     try:
         os.getpgid(pid)
-    except OSError, x:
+    except OSError as x:
         if x.errno == 3:
             return False
         logging.error("Unknown exception from getpgid - %s", str(x))

=== modified file 'lib/lp/scripts/utilities/pageperformancereport.py'
--- lib/lp/scripts/utilities/pageperformancereport.py	2012-03-14 04:41:36 +0000
+++ lib/lp/scripts/utilities/pageperformancereport.py	2012-06-29 08:46:59 +0000
@@ -730,7 +730,7 @@
         regexp = script_config.get('categories', option)
         try:
             categories.append(Category(option, regexp))
-        except sre_constants.error, x:
+        except sre_constants.error as x:
             log.fatal("Unable to compile regexp %r (%s)" % (regexp, x))
             return 1
     categories.sort()
@@ -971,7 +971,7 @@
                     times.add_request(request)
                 else:
                     raise MalformedLine('Unknown record type %s', record_type)
-            except MalformedLine, x:
+            except MalformedLine as x:
                 log.error(
                     "Malformed line %s (%s)" % (repr(line), x))
 

=== modified file 'lib/lp/services/apachelogparser/base.py'
--- lib/lp/services/apachelogparser/base.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/apachelogparser/base.py	2012-06-29 08:46:59 +0000
@@ -160,7 +160,7 @@
             daily_downloads[country_code] += 1
         except (KeyboardInterrupt, SystemExit):
             raise
-        except Exception, e:
+        except Exception as e:
             # Update parsed_bytes to the end of the last line we parsed
             # successfully, log this as an error and break the loop so that
             # we return.

=== modified file 'lib/lp/services/command_spawner.py'
--- lib/lp/services/command_spawner.py	2011-12-19 23:38:16 +0000
+++ lib/lp/services/command_spawner.py	2012-06-29 08:46:59 +0000
@@ -171,7 +171,7 @@
         """Read output from `pipe_file`."""
         try:
             output = pipe_file.read()
-        except IOError, e:
+        except IOError as e:
             # "Resource temporarily unavailable"--not an error really,
             # just means there's nothing to read.
             if e.errno != errno.EAGAIN:

=== modified file 'lib/lp/services/config/__init__.py'
--- lib/lp/services/config/__init__.py	2012-02-24 16:51:25 +0000
+++ lib/lp/services/config/__init__.py	2012-06-29 08:46:59 +0000
@@ -215,7 +215,7 @@
         self._config = schema.load(config_file)
         try:
             self._config.validate()
-        except ConfigErrors, error:
+        except ConfigErrors as error:
             message = '\n'.join([str(e) for e in error.errors])
             raise ConfigErrors(message)
         self._setZConfig()

=== modified file 'lib/lp/services/config/tests/test_config.py'
--- lib/lp/services/config/tests/test_config.py	2012-05-03 16:21:22 +0000
+++ lib/lp/services/config/tests/test_config.py	2012-06-29 08:46:59 +0000
@@ -62,7 +62,7 @@
             config = schema.load(config_file)
             try:
                 config.validate()
-            except ConfigErrors, error:
+            except ConfigErrors as error:
                 message = '\n'.join([str(e) for e in error.errors])
                 self.fail(message)
     # Hack the config file name into the class name.

=== modified file 'lib/lp/services/doc/pidfile.txt'
--- lib/lp/services/doc/pidfile.txt	2011-12-30 08:13:14 +0000
+++ lib/lp/services/doc/pidfile.txt	2012-06-29 08:46:59 +0000
@@ -105,7 +105,7 @@
     ...         try:
     ...             # Is it still here at all?
     ...             os.kill(pid, 0)
-    ...         except OSError, e:
+    ...         except OSError as e:
     ...             if e.errno == errno.ESRCH:
     ...                 print 'Error: pid file was not removed'
     ...             else: raise

=== modified file 'lib/lp/services/features/browser/edit.py'
--- lib/lp/services/features/browser/edit.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/features/browser/edit.py	2012-06-29 08:46:59 +0000
@@ -114,5 +114,6 @@
             # Unfortunately if the field is '', zope leaves it out of data.
             self.request.features.rule_source.parseRules(
                 data.get('feature_rules') or '')
-        except (IndexError, TypeError, ValueError, DuplicatePriorityError), e:
+        except (IndexError, TypeError, ValueError,
+                DuplicatePriorityError) as e:
             self.setFieldError('feature_rules', 'Invalid rule syntax: %s' % e)

=== modified file 'lib/lp/services/fields/__init__.py'
--- lib/lp/services/fields/__init__.py	2012-06-02 11:53:05 +0000
+++ lib/lp/services/fields/__init__.py	2012-06-29 08:46:59 +0000
@@ -625,7 +625,7 @@
         input = input.strip()
         try:
             uri = URI(input)
-        except InvalidURIError, exc:
+        except InvalidURIError as exc:
             raise LaunchpadValidationError(str(exc))
         # If there is a policy for whether trailing slashes are
         # allowed at the end of the path segment, ensure that the

=== modified file 'lib/lp/services/googlesearch/__init__.py'
--- lib/lp/services/googlesearch/__init__.py	2011-12-30 08:13:14 +0000
+++ lib/lp/services/googlesearch/__init__.py	2012-06-29 08:46:59 +0000
@@ -211,7 +211,7 @@
         action = timeline.start("google-search-api", search_url)
         try:
             gsp_xml = urlfetch(search_url)
-        except (TimeoutError, urllib2.HTTPError, urllib2.URLError), error:
+        except (TimeoutError, urllib2.HTTPError, urllib2.URLError) as error:
             # Google search service errors are not code errors. Let the
             # call site choose to handle the unavailable service.
             raise GoogleResponseError(

=== modified file 'lib/lp/services/googlesearch/googletestservice.py'
--- lib/lp/services/googlesearch/googletestservice.py	2011-12-30 08:13:14 +0000
+++ lib/lp/services/googlesearch/googletestservice.py	2012-06-29 08:46:59 +0000
@@ -132,7 +132,7 @@
         while True:
             try:
                 sock.connect((host, port))
-            except socket.error, err:
+            except socket.error as err:
                 if err.args[0] in [errno.ECONNREFUSED, errno.ECONNABORTED]:
                     elapsed = (time.time() - start)
                     if elapsed > timeout:
@@ -166,7 +166,7 @@
             try:
                 sock.connect((host, port))
                 sock.close()
-            except socket.error, err:
+            except socket.error as err:
                 if err.args[0] == errno.ECONNREFUSED:
                     # Success!  The socket is closed.
                     return
@@ -231,7 +231,7 @@
                 # between freeing the socket in the killed process, and
                 # opening it in the current one.
                 wait_for_service_shutdown()
-            except os.error, err:
+            except os.error as err:
                 if err.errno == errno.ESRCH:
                     # Whoops, we got a 'No such process' error. The PID file
                     # is probably stale, so we'll remove it to prevent trash
@@ -246,7 +246,7 @@
     """Unlink a file, but don't raise an error if the file is missing."""
     try:
         os.unlink(filepath)
-    except os.error, err:
+    except os.error as err:
         if err.errno != errno.ENOENT:
             raise
 

=== modified file 'lib/lp/services/googlesearch/tests/googleserviceharness.py'
--- lib/lp/services/googlesearch/tests/googleserviceharness.py	2011-12-29 05:29:36 +0000
+++ lib/lp/services/googlesearch/tests/googleserviceharness.py	2012-06-29 08:46:59 +0000
@@ -97,7 +97,7 @@
         if cls.service:
             try:
                 os.kill(cls.service.pid, signal.SIGTERM)
-            except OSError, error:
+            except OSError as error:
                 if error.errno != errno.ESRCH:
                     raise
                 # The process with the given pid doesn't exist, so there's

=== modified file 'lib/lp/services/googlesearch/tests/test_googleservice.py'
--- lib/lp/services/googlesearch/tests/test_googleservice.py	2011-12-30 08:13:14 +0000
+++ lib/lp/services/googlesearch/tests/test_googleservice.py	2012-06-29 08:46:59 +0000
@@ -41,7 +41,7 @@
     """Return True if the specified process already exists."""
     try:
         os.kill(pid, 0)
-    except os.error, err:
+    except os.error as err:
         if err.errno == errno.ESRCH:
             # All is well - the process doesn't exist.
             return False

=== modified file 'lib/lp/services/gpg/doc/gpg-signatures.txt'
--- lib/lp/services/gpg/doc/gpg-signatures.txt	2011-12-24 17:49:30 +0000
+++ lib/lp/services/gpg/doc/gpg-signatures.txt	2012-06-29 08:46:59 +0000
@@ -217,7 +217,7 @@
     ... """
     >>> try:
     ...     gpghandler.getVerifiedSignature(content)
-    ... except GPGVerificationError, e:
+    ... except GPGVerificationError as e:
     ...     print e.args
     ...     print e.code
     ...     print e.signatures

=== modified file 'lib/lp/services/gpg/handler.py'
--- lib/lp/services/gpg/handler.py	2012-03-26 07:14:35 +0000
+++ lib/lp/services/gpg/handler.py	2012-06-29 08:46:59 +0000
@@ -143,7 +143,7 @@
         for i in range(3):
             try:
                 signature = self.getVerifiedSignature(content, signature)
-            except GPGVerificationError, info:
+            except GPGVerificationError as info:
                 errors.append(info)
             else:
                 return signature
@@ -186,7 +186,7 @@
         # process it
         try:
             signatures = ctx.verify(*args)
-        except gpgme.GpgmeError, e:
+        except gpgme.GpgmeError as e:
             # XXX: 2010-04-26, Salgado, bug=570244: This hack is needed
             # for python2.5 compatibility. We should remove it when we no
             # longer need to run on python2.5.
@@ -453,7 +453,7 @@
 
         try:
             conn.request("POST", "/pks/add", params, headers)
-        except socket.error, err:
+        except socket.error as err:
             raise GPGUploadFailure(
                 'Could not reach keyserver at http://%s %s' % (
                     keyserver_http_url, str(err)))
@@ -495,7 +495,7 @@
         # minutes." The details of the error do not matter for users
         # (and for the code in callsites), but we should be able to see
         # if this problem occurs too often.
-        except urllib2.HTTPError, exc:
+        except urllib2.HTTPError as exc:
             # The key server behaves a bit odd when queried for non
             # existent keys: Instead of responding with a 404, it
             # returns a 500 error. But we can extract the fact that
@@ -507,7 +507,7 @@
                     raise GPGKeyDoesNotExistOnServer(fingerprint)
                 errorlog.globalErrorUtility.raising(sys.exc_info(), request)
                 raise GPGKeyTemporarilyNotFoundError(fingerprint)
-        except (TimeoutError, urllib2.URLError), exc:
+        except (TimeoutError, urllib2.URLError) as exc:
             errorlog.globalErrorUtility.raising(sys.exc_info(), request)
             raise GPGKeyTemporarilyNotFoundError(fingerprint)
         finally:

=== modified file 'lib/lp/services/job/celeryconfig.py'
--- lib/lp/services/job/celeryconfig.py	2012-06-14 05:18:22 +0000
+++ lib/lp/services/job/celeryconfig.py	2012-06-29 08:46:59 +0000
@@ -100,6 +100,6 @@
 
 try:
     globals().update(configure(getattr(sys, 'argv', [''])))
-except ConfigurationError, error:
+except ConfigurationError as error:
     print >>sys.stderr, error
     sys.exit(1)

=== modified file 'lib/lp/services/librarian/client.py'
--- lib/lp/services/librarian/client.py	2011-12-30 06:14:56 +0000
+++ lib/lp/services/librarian/client.py	2012-06-29 08:46:59 +0000
@@ -94,7 +94,7 @@
             self.state.s = socket.socket(AF_INET, SOCK_STREAM)
             self.state.s.connect((self.upload_host, self.upload_port))
             self.state.f = self.state.s.makefile('w+', 0)
-        except socket.error, x:
+        except socket.error as x:
             raise UploadFailed(
                 '[%s:%s]: %s' % (self.upload_host, self.upload_port, x))
 
@@ -482,7 +482,7 @@
         while 1:
             try:
                 return _File(urllib2.urlopen(url), url)
-            except urllib2.URLError, error:
+            except urllib2.URLError as error:
                 # 404 errors indicate a data inconsistency: more than one
                 # attempt to open the file is pointless.
                 #

=== modified file 'lib/lp/services/librarian/tests/test_client.py'
--- lib/lp/services/librarian/tests/test_client.py	2011-12-30 06:14:56 +0000
+++ lib/lp/services/librarian/tests/test_client.py	2012-06-29 08:46:59 +0000
@@ -104,7 +104,7 @@
         client._getDatabaseName = lambda cur: 'wrong_database'
         try:
             client.addFile('sample.txt', 6, StringIO('sample'), 'text/plain')
-        except UploadFailed, e:
+        except UploadFailed as e:
             msg = e.args[0]
             self.failUnless(
                 msg.startswith('Server said: 400 Wrong database'),

=== modified file 'lib/lp/services/librarianserver/librariangc.py'
--- lib/lp/services/librarianserver/librariangc.py	2012-01-06 11:08:30 +0000
+++ lib/lp/services/librarianserver/librariangc.py	2012-06-29 08:46:59 +0000
@@ -486,7 +486,7 @@
             path = get_file_path(content_id)
             try:
                 os.unlink(path)
-            except OSError, e:
+            except OSError as e:
                 if e.errno != errno.ENOENT:
                     raise
                 if config.librarian_server.upstream_host is None:

=== modified file 'lib/lp/services/librarianserver/libraryprotocol.py'
--- lib/lp/services/librarianserver/libraryprotocol.py	2011-12-30 01:48:17 +0000
+++ lib/lp/services/librarianserver/libraryprotocol.py	2012-06-29 08:46:59 +0000
@@ -68,7 +68,7 @@
     def lineReceived(self, line):
         try:
             getattr(self, 'line_' + self.state, self.badLine)(line)
-        except ProtocolViolation, e:
+        except ProtocolViolation as e:
             self.sendError(e.msg)
         except:
             self.unknownError()

=== modified file 'lib/lp/services/librarianserver/storage.py'
--- lib/lp/services/librarianserver/storage.py	2011-12-30 06:14:56 +0000
+++ lib/lp/services/librarianserver/storage.py	2012-06-29 08:46:59 +0000
@@ -65,7 +65,7 @@
         self.incoming = os.path.join(self.directory, 'incoming')
         try:
             os.mkdir(self.incoming)
-        except OSError, e:
+        except OSError as e:
             if e.errno != errno.EEXIST:
                 raise
 
@@ -191,7 +191,7 @@
             raise DuplicateFileIDError(fileID)
         try:
             os.makedirs(os.path.dirname(location))
-        except OSError, e:
+        except OSError as e:
             # If the directory already exists, that's ok.
             if e.errno != errno.EEXIST:
                 raise

=== modified file 'lib/lp/services/librarianserver/tests/test_db_outage.py'
--- lib/lp/services/librarianserver/tests/test_db_outage.py	2011-12-30 01:48:17 +0000
+++ lib/lp/services/librarianserver/tests/test_db_outage.py	2012-06-29 08:46:59 +0000
@@ -89,7 +89,7 @@
             try:
                 urllib2.urlopen(self.url).read()
                 codes.add(200)
-            except urllib2.HTTPError, error:
+            except urllib2.HTTPError as error:
                 codes.add(error.code)
         self.assertTrue(len(codes) == 1, 'Mixed responses: %s' % str(codes))
         return codes.pop()

=== modified file 'lib/lp/services/librarianserver/tests/test_web.py'
--- lib/lp/services/librarianserver/tests/test_web.py	2012-01-20 16:11:11 +0000
+++ lib/lp/services/librarianserver/tests/test_web.py	2012-06-29 08:46:59 +0000
@@ -373,7 +373,7 @@
         try:
             urlopen(url)
             self.fail('404 not raised')
-        except HTTPError, e:
+        except HTTPError as e:
             self.failUnlessEqual(e.code, 404)
 
 
@@ -479,5 +479,5 @@
         try:
             urlopen(url)
             self.fail('404 not raised')
-        except HTTPError, x:
+        except HTTPError as x:
             self.failUnlessEqual(x.code, 404)

=== modified file 'lib/lp/services/mail/basemailer.py'
--- lib/lp/services/mail/basemailer.py	2011-12-23 22:27:40 +0000
+++ lib/lp/services/mail/basemailer.py	2012-06-29 08:46:59 +0000
@@ -153,14 +153,14 @@
             try:
                 ctrl = self.generateEmail(email, recipient)
                 ctrl.send()
-            except SMTPException, e:
+            except SMTPException as e:
                 # If the initial sending failed, try again without
                 # attachments.
                 try:
                     ctrl = self.generateEmail(
                         email, recipient, force_no_attachments=True)
                     ctrl.send()
-                except SMTPException, e:
+                except SMTPException as e:
                     # Don't want an entire stack trace, just some details.
                     self.logger.warning(
                         'send failed for %s, %s' % (email, e))

=== modified file 'lib/lp/services/mail/incoming.py'
--- lib/lp/services/mail/incoming.py	2012-04-16 00:14:36 +0000
+++ lib/lp/services/mail/incoming.py	2012-06-29 08:46:59 +0000
@@ -141,17 +141,17 @@
     try:
         dkim_result = dkim.verify(
             signed_message.parsed_string, dkim_log, details=signing_details)
-    except dkim.DKIMException, e:
+    except dkim.DKIMException as e:
         log.warning('DKIM error: %r' % (e,))
-    except dns.resolver.NXDOMAIN, e:
+    except dns.resolver.NXDOMAIN as e:
         # This can easily happen just through bad input data, ie claiming to
         # be signed by a domain with no visible key of that name.  It's not an
         # operational error.
         log.info('DNS exception: %r' % (e,))
-    except dns.exception.DNSException, e:
+    except dns.exception.DNSException as e:
         # many of them have lame messages, thus %r
         log.warning('DNS exception: %r' % (e,))
-    except Exception, e:
+    except Exception as e:
         # DKIM leaks some errors when it gets bad input, as in bug 881237.  We
         # don't generally want them to cause the mail to be dropped entirely
         # though.  It probably is reasonable to treat them as potential
@@ -307,7 +307,7 @@
         sig = gpghandler.getVerifiedSignature(
             canonicalise_line_endings(mail.signedContent), signature)
         log.debug("got signature %r" % sig)
-    except GPGVerificationError, e:
+    except GPGVerificationError as e:
         # verifySignature failed to verify the signature.
         message = "Signature couldn't be verified: %s" % e
         log.debug(message)
@@ -521,7 +521,7 @@
     try:
         principal = authenticateEmail(
             mail, signature_timestamp_checker)
-    except InvalidSignature, error:
+    except InvalidSignature as error:
         send_process_error_notification(
             mail['From'], 'Submit Request Failure', str(error), mail)
         return
@@ -534,7 +534,7 @@
 
     try:
         do_paranoid_envelope_to_validation(addresses)
-    except AssertionError, e:
+    except AssertionError as e:
         log.info("Invalid email address: %s" % e)
         return
 

=== modified file 'lib/lp/services/mail/mailbox.py'
--- lib/lp/services/mail/mailbox.py	2011-08-12 14:36:25 +0000
+++ lib/lp/services/mail/mailbox.py	2012-06-29 08:46:59 +0000
@@ -115,12 +115,12 @@
                 popbox = poplib.POP3_SSL(self._host)
             else:
                 popbox = poplib.POP3(self._host)
-        except socket.error, e:
+        except socket.error as e:
             raise MailBoxError(str(e))
         try:
             popbox.user(self._user)
             popbox.pass_(self._password)
-        except poplib.error_proto, e:
+        except poplib.error_proto as e:
             popbox.quit()
             raise MailBoxError(str(e))
         self._popbox = popbox
@@ -130,7 +130,7 @@
         popbox = self._popbox
         try:
             count, size = popbox.stat()
-        except poplib.error_proto, e:
+        except poplib.error_proto as e:
             # This means we lost the connection.
             raise MailBoxError(str(e))
 
@@ -142,7 +142,7 @@
         """See IMailBox."""
         try:
             self._popbox.dele(id)
-        except poplib.error_proto, e:
+        except poplib.error_proto as e:
             raise MailBoxError(str(e))
 
     def close(self):

=== modified file 'lib/lp/services/mailman/doc/logging.txt'
--- lib/lp/services/mailman/doc/logging.txt	2012-01-01 02:25:04 +0000
+++ lib/lp/services/mailman/doc/logging.txt	2012-06-29 08:46:59 +0000
@@ -18,7 +18,7 @@
     ...     """Raise an error to test log_exception."""
     ...     try:
     ...         raise AssertionError("There is an OOPS in progress.")
-    ...     except AssertionError, error:
+    ...     except AssertionError as error:
     ...         log_exception('Generated Error: %s', error)
 
     >>> from lp.testing.fixture import CaptureOops

=== modified file 'lib/lp/services/mailman/monkeypatches/lphandler.py'
--- lib/lp/services/mailman/monkeypatches/lphandler.py	2011-12-19 23:38:16 +0000
+++ lib/lp/services/mailman/monkeypatches/lphandler.py	2012-06-29 08:46:59 +0000
@@ -48,7 +48,7 @@
     # processing at this handler.
     try:
         is_member = proxy.isRegisteredInLaunchpad(sender)
-    except Exception, error:
+    except Exception as error:
         XMLRPCRunner.handle_proxy_error(error, msg, msgdata)
     # This handler can just return if the sender is a member of Launchpad.
     if is_member:

=== modified file 'lib/lp/services/mailman/monkeypatches/lpstanding.py'
--- lib/lp/services/mailman/monkeypatches/lpstanding.py	2011-01-18 02:42:08 +0000
+++ lib/lp/services/mailman/monkeypatches/lpstanding.py	2012-06-29 08:46:59 +0000
@@ -30,7 +30,7 @@
     # processing at this handler.
     try:
         in_good_standing = proxy.inGoodStanding(sender)
-    except Exception, error:
+    except Exception as error:
         XMLRPCRunner.handle_proxy_error(error, msg, msgdata)
     # If the sender is a member in good standing, that's all we need to know
     # in order to let the message pass.

=== modified file 'lib/lp/services/mailman/monkeypatches/xmlrpcrunner.py'
--- lib/lp/services/mailman/monkeypatches/xmlrpcrunner.py	2012-01-01 02:23:25 +0000
+++ lib/lp/services/mailman/monkeypatches/xmlrpcrunner.py	2012-06-29 08:46:59 +0000
@@ -172,10 +172,10 @@
         """See if there are any list actions to perform."""
         try:
             actions = self._proxy.getPendingActions()
-        except (xmlrpclib.ProtocolError, socket.error), error:
+        except (xmlrpclib.ProtocolError, socket.error) as error:
             log_exception('Cannot talk to Launchpad:\n%s', error)
             return
-        except xmlrpclib.Fault, error:
+        except xmlrpclib.Fault as error:
             log_exception('Launchpad exception: %s', error)
             return
         if actions:
@@ -222,9 +222,9 @@
             try:
                 self._proxy.reportStatus(this_status)
                 syslog('xmlrpc', '[%s] %s: %s' % (team_name, action, status))
-            except (xmlrpclib.ProtocolError, socket.error), error:
+            except (xmlrpclib.ProtocolError, socket.error) as error:
                 log_exception('Cannot talk to Launchpad:\n%s', error)
-            except xmlrpclib.Fault, error:
+            except xmlrpclib.Fault as error:
                 log_exception('Launchpad exception: %s', error)
 
     def _update_list_subscriptions(self, list_name, subscription_info):
@@ -354,11 +354,11 @@
             # Get the information for this batch of mailing lists.
             try:
                 info = self._proxy.getMembershipInformation(batch)
-            except (xmlrpclib.ProtocolError, socket.error), error:
+            except (xmlrpclib.ProtocolError, socket.error) as error:
                 log_exception('Cannot talk to Launchpad: %s', error)
                 syslog('xmlrpc', 'batch: %s', batch)
                 continue
-            except xmlrpclib.Fault, error:
+            except xmlrpclib.Fault as error:
                 log_exception('Launchpad exception: %s', error)
                 syslog('xmlrpc', 'batch: %s', batch)
                 continue
@@ -409,7 +409,7 @@
                 mm_cfg.VAR_PREFIX, 'backups', team_name + '.tgz')
             try:
                 tgz_file = tarfile.open(tgz_file_name, 'r:gz')
-            except IOError, error:
+            except IOError as error:
                 if error.errno != errno.ENOENT:
                     raise
                 # The archive tarfile does not exist, meaning this is the
@@ -593,10 +593,10 @@
         """See if any held messages have been accepted or rejected."""
         try:
             dispositions = self._proxy.getMessageDispositions()
-        except (xmlrpclib.ProtocolError, socket.error), error:
+        except (xmlrpclib.ProtocolError, socket.error) as error:
             log_exception('Cannot talk to Launchpad:\n%s', error)
             return
-        except xmlrpclib.Fault, error:
+        except xmlrpclib.Fault as error:
             log_exception('Launchpad exception: %s', error)
             return
         if dispositions:
@@ -732,5 +732,5 @@
             tgz_file.chown(tarinfo, path)
             tgz_file.utime(tarinfo, path)
             tgz_file.chmod(tarinfo, path)
-        except tarfile.ExtractError, e:
+        except tarfile.ExtractError as e:
             log_exception('xmlrpc', 'tarfile: %s', e)

=== modified file 'lib/lp/services/mailman/runmailman.py'
--- lib/lp/services/mailman/runmailman.py	2011-12-30 09:38:59 +0000
+++ lib/lp/services/mailman/runmailman.py	2012-06-29 08:46:59 +0000
@@ -72,7 +72,7 @@
     master_pid_path = os.path.join(mailman_path, 'data', 'master-qrunner.pid')
     try:
         master_pid_file = open(master_pid_path)
-    except IOError, error:
+    except IOError as error:
         if error.errno == errno.ENOENT:
             # It doesn't exist, so we're all done.
             return
@@ -84,7 +84,7 @@
     try:
         # Kill the entire process group.
         os.kill(master_pid, -signal.SIGKILL)
-    except OSError, error:
+    except OSError as error:
         if error.errno == errno.ESRCH:
             # The process does not exist.  It could be a zombie that has yet
             # to be waited on, but let's not worry about that.
@@ -92,7 +92,7 @@
         raise
     try:
         os.remove(master_pid_path)
-    except OSError, error:
+    except OSError as error:
         if error.errno != errno.ENOENT:
             raise
     lock_dir = os.path.join(mailman_path, 'locks')

=== modified file 'lib/lp/services/mailman/testing/helpers.py'
--- lib/lp/services/mailman/testing/helpers.py	2012-01-01 02:37:00 +0000
+++ lib/lp/services/mailman/testing/helpers.py	2012-06-29 08:46:59 +0000
@@ -71,7 +71,7 @@
     """Return the size of a file, or -1 if it doesn't exist."""
     try:
         return os.stat(path).st_size
-    except OSError, error:
+    except OSError as error:
         if error.errno == errno.ENOENT:
             # Return -1 when the file does not exist, so it always
             # compares less than an existing but empty file.
@@ -214,7 +214,7 @@
             archived_files = [file_name
                               for file_name in os.listdir(mhonarc_path)
                               if file_name.endswith('.html')]
-        except OSError, error:
+        except OSError as error:
             if error.errno != errno.ENOENT:
                 raise
             # Sleep and try again.

=== modified file 'lib/lp/services/mailman/tests/test_mailman.py'
--- lib/lp/services/mailman/tests/test_mailman.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/mailman/tests/test_mailman.py	2012-06-29 08:46:59 +0000
@@ -83,14 +83,14 @@
             VAR_PREFIX, 'backups', '%s.tgz' % team_name)
         try:
             os.remove(backup_file)
-        except OSError, error:
+        except OSError as error:
             if error.errno != errno.ENOENT:
                 raise
         # Delete the MHonArc archives if they exist.
         path = os.path.join(VAR_PREFIX, 'mhonarc', team_name)
         try:
             shutil.rmtree(path)
-        except OSError, error:
+        except OSError as error:
             if error.errno != errno.ENOENT:
                 raise
     # Remove all held messages.

=== modified file 'lib/lp/services/messaging/rabbit.py'
--- lib/lp/services/messaging/rabbit.py	2012-04-24 04:23:52 +0000
+++ lib/lp/services/messaging/rabbit.py	2012-06-29 08:46:59 +0000
@@ -281,7 +281,7 @@
                 else:
                     self.channel.basic_ack(message.delivery_tag)
                     return json.loads(message.body)
-            except amqp.AMQPChannelException, error:
+            except amqp.AMQPChannelException as error:
                 if error.amqp_reply_code == 404:
                     raise QueueNotFound()
                 else:

=== modified file 'lib/lp/services/osutils.py'
--- lib/lp/services/osutils.py	2012-05-31 11:46:17 +0000
+++ lib/lp/services/osutils.py	2012-06-29 08:46:59 +0000
@@ -79,11 +79,11 @@
     for i in range(retries):
         try:
             return function(*args, **kwargs)
-        except (IOError, OSError), e:
+        except (IOError, OSError) as e:
             if e.errno == errno.EINTR:
                 continue
             raise
-        except socket.error, e:
+        except socket.error as e:
             # In Python 2.6 we can use IOError instead.  It also has
             # reason.errno but we might be using 2.5 here so use the
             # index hack.
@@ -101,7 +101,7 @@
     """
     try:
         os.makedirs(directory, mode=mode)
-    except OSError, e:
+    except OSError as e:
         if e.errno == errno.EEXIST:
             return False
         raise
@@ -121,7 +121,7 @@
     """
     try:
         return open(filename, mode)
-    except IOError, e:
+    except IOError as e:
         if e.errno == errno.ENOENT:
             os.makedirs(os.path.dirname(filename), mode=dirmode)
             return open(filename, mode)
@@ -131,7 +131,7 @@
     """Kill a pid accepting that it may not exist."""
     try:
         os.kill(pid, signal_number)
-    except OSError, e:
+    except OSError as e:
         if e.errno in (errno.ESRCH, errno.ECHILD):
             # Process has already been killed.
             return
@@ -159,7 +159,7 @@
             if new_pid:
                 return result
             time.sleep(poll_interval)
-        except OSError, e:
+        except OSError as e:
             if e.errno in (errno.ESRCH, errno.ECHILD):
                 # Raised if the process is gone by the time we try to get the
                 # return value.
@@ -201,7 +201,7 @@
     """Remove the given file if it exists."""
     try:
         os.remove(path)
-    except OSError, e:
+    except OSError as e:
         if e.errno != errno.ENOENT:
             raise
 

=== modified file 'lib/lp/services/salesforce/proxy.py'
--- lib/lp/services/salesforce/proxy.py	2011-12-30 08:13:14 +0000
+++ lib/lp/services/salesforce/proxy.py	2012-06-29 08:46:59 +0000
@@ -46,7 +46,7 @@
     def decorator(*args, **kwargs):
         try:
             results = func(*args, **kwargs)
-        except Fault, fault:
+        except Fault as fault:
             exception = errorcode_map.get(fault.faultCode,
                                           SalesforceVoucherProxyException)
             raise exception(fault.faultString)

=== modified file 'lib/lp/services/scripts/base.py'
--- lib/lp/services/scripts/base.py	2012-05-31 10:30:03 +0000
+++ lib/lp/services/scripts/base.py	2012-06-29 08:46:59 +0000
@@ -339,10 +339,10 @@
                 profiler.runcall(self.main)
             else:
                 self.main()
-        except LaunchpadScriptFailure, e:
+        except LaunchpadScriptFailure as e:
             self.logger.error(str(e))
             sys.exit(e.exit_status)
-        except SilentLaunchpadScriptFailure, e:
+        except SilentLaunchpadScriptFailure as e:
             sys.exit(e.exit_status)
         else:
             date_completed = datetime.datetime.now(UTC)
@@ -457,13 +457,13 @@
         # seconds.
         control_fp = urlopen(control_url, timeout=5)
     # Yuck. API makes it hard to catch 'does not exist'.
-    except HTTPError, error:
+    except HTTPError as error:
         if error.code == 404:
             log.debug("Cronscript control file not found at %s", control_url)
             return True
         log.exception("Error loading %s" % control_url)
         return True
-    except URLError, error:
+    except URLError as error:
         if getattr(error.reason, 'errno', None) == 2:
             log.debug("Cronscript control file not found at %s", control_url)
             return True

=== modified file 'lib/lp/services/temporaryblobstorage/browser.py'
--- lib/lp/services/temporaryblobstorage/browser.py	2011-12-30 02:24:09 +0000
+++ lib/lp/services/temporaryblobstorage/browser.py	2012-06-29 08:46:59 +0000
@@ -64,7 +64,7 @@
         except BlobTooLarge:
             self.addError('Uploaded file was too large.')
             return None
-        except UploadFailed, e:
+        except UploadFailed as e:
             self.addError('File storage unavailable - try again later.')
             return None
         else:

=== modified file 'lib/lp/services/twistedsupport/__init__.py'
--- lib/lp/services/twistedsupport/__init__.py	2011-06-20 20:07:33 +0000
+++ lib/lp/services/twistedsupport/__init__.py	2012-06-29 08:46:59 +0000
@@ -137,7 +137,7 @@
     def wrapped(*args, **kwargs):
         try:
             return func(*args, **kwargs)
-        except BaseException, e:
+        except BaseException as e:
             return Failure(e)
 
     return wrapped

=== modified file 'lib/lp/services/twistedsupport/tests/test_xmlrpc.py'
--- lib/lp/services/twistedsupport/tests/test_xmlrpc.py	2010-10-30 23:15:55 +0000
+++ lib/lp/services/twistedsupport/tests/test_xmlrpc.py	2012-06-29 08:46:59 +0000
@@ -52,7 +52,7 @@
     def assertRaisesFailure(self, failure, function, *args, **kwargs):
         try:
             function(*args, **kwargs)
-        except Failure, raised_failure:
+        except Failure as raised_failure:
             self.assertEqual(failure, raised_failure)
 
     def test_raises_non_faults(self):

=== modified file 'lib/lp/services/verification/browser/logintoken.py'
--- lib/lp/services/verification/browser/logintoken.py	2012-06-13 21:40:11 +0000
+++ lib/lp/services/verification/browser/logintoken.py	2012-06-29 08:46:59 +0000
@@ -246,7 +246,7 @@
         try:
             self.claimed_profile.convertToTeam(
                 team_owner=self.context.requester)
-        except AlreadyConvertedException, e:
+        except AlreadyConvertedException as e:
             self.request.response.addErrorNotification(e)
             self.context.consume()
             return
@@ -316,7 +316,7 @@
         try:
             signature = getUtility(IGPGHandler).getVerifiedSignature(
                 signedcontent.encode('ASCII'))
-        except (GPGVerificationError, UnicodeEncodeError), e:
+        except (GPGVerificationError, UnicodeEncodeError) as e:
             self.addError(_(
                 'Launchpad could not verify your signature: ${err}',
                 mapping=dict(err=str(e))))
@@ -401,7 +401,7 @@
                 'YOU</kdb>). Try later or <a href="${url}/+editpgpkeys"> '
                 'cancel your request</a>.',
                 mapping=dict(fingerprint=fingerprint, url=person_url))))
-        except GPGKeyRevoked, e:
+        except GPGKeyRevoked as e:
             # If key is globally revoked, skip the import and consume the
             # token.
             self.addError(
@@ -412,7 +412,7 @@
                 'process to <a href="${url}/+editpgpkeys">find and '
                 'import</a> the new key.',
                 mapping=dict(key=e.key.keyid, url=person_url))))
-        except GPGKeyExpired, e:
+        except GPGKeyExpired as e:
             self.addError(
                         structured(_(
                 'The key ${key} cannot be validated because it has expired. '

=== modified file 'lib/lp/services/webapp/adapter.py'
--- lib/lp/services/webapp/adapter.py	2012-04-06 17:28:25 +0000
+++ lib/lp/services/webapp/adapter.py	2012-06-29 08:46:59 +0000
@@ -481,7 +481,7 @@
         try:
             return super(ReadOnlyModeConnection, self).execute(
                 statement, params, noresult)
-        except psycopg2.InternalError, exception:
+        except psycopg2.InternalError as exception:
             # Error 25006 is 'ERROR:  transaction is read-only'. This
             # is raised when an attempt is made to make changes when
             # the connection has been put in read-only mode.

=== modified file 'lib/lp/services/webapp/batching.py'
--- lib/lp/services/webapp/batching.py	2012-03-26 04:35:37 +0000
+++ lib/lp/services/webapp/batching.py	2012-06-29 08:46:59 +0000
@@ -387,7 +387,7 @@
             expression = plain_expression(expression)
             try:
                 expression.variable_factory(value=value)
-            except TypeError, error:
+            except TypeError as error:
                 # A TypeError is raised when the type of value cannot
                 # be used for expression. All expected types are
                 # properly created by simplejson.loads() above, except

=== modified file 'lib/lp/services/webapp/publisher.py'
--- lib/lp/services/webapp/publisher.py	2012-06-14 05:18:22 +0000
+++ lib/lp/services/webapp/publisher.py	2012-06-29 08:46:59 +0000
@@ -325,7 +325,7 @@
         # infrastructure.
         try:
             cache = IJSONRequestCache(self.request).objects
-        except TypeError, error:
+        except TypeError as error:
             if error.args[0] == 'Could not adapt':
                 cache = None
         return cache

=== modified file 'lib/lp/services/webapp/tests/test_error.py'
--- lib/lp/services/webapp/tests/test_error.py	2012-06-22 15:37:20 +0000
+++ lib/lp/services/webapp/tests/test_error.py	2012-06-29 08:46:59 +0000
@@ -62,7 +62,7 @@
     def getHTTPError(self, url):
         try:
             urllib2.urlopen(url)
-        except urllib2.HTTPError, error:
+        except urllib2.HTTPError as error:
             return error
         else:
             self.fail("We should have gotten an HTTP error")

=== modified file 'lib/lp/services/webapp/tests/test_errorlog.py'
--- lib/lp/services/webapp/tests/test_errorlog.py	2012-05-15 07:15:17 +0000
+++ lib/lp/services/webapp/tests/test_errorlog.py	2012-06-29 08:46:59 +0000
@@ -715,7 +715,7 @@
         converter = module.get_converter('int')
         try:
             converter(42)
-        except ValueError, e:
+        except ValueError as e:
             self.assertTrue(IUnloggedException.providedBy(e))
 
     def test_other_errors_not_marked(self):
@@ -734,7 +734,7 @@
         converter = module.get_converter('int')
         try:
             converter(42)
-        except RuntimeError, e:
+        except RuntimeError as e:
             self.assertFalse(IUnloggedException.providedBy(e))
 
     def test_none_is_not_wrapped(self):

=== modified file 'lib/lp/services/webservice/doc/webservice-error.txt'
--- lib/lp/services/webservice/doc/webservice-error.txt	2011-12-24 17:49:30 +0000
+++ lib/lp/services/webservice/doc/webservice-error.txt	2012-06-29 08:46:59 +0000
@@ -17,7 +17,7 @@
     ...     """
     ...     try:
     ...         raise error
-    ...     except Exception, error:
+    ...     except Exception as error:
     ...         request = LaunchpadTestRequest(
     ...             environ={'PATH_INFO' : ''})
     ...         set_request_started()

=== modified file 'lib/lp/soyuz/adapters/packagelocation.py'
--- lib/lp/soyuz/adapters/packagelocation.py	2010-08-23 16:51:11 +0000
+++ lib/lp/soyuz/adapters/packagelocation.py	2012-06-29 08:46:59 +0000
@@ -101,7 +101,7 @@
 
     try:
         distribution = getUtility(IDistributionSet)[distribution_name]
-    except NotFoundError, err:
+    except NotFoundError as err:
         raise PackageLocationError(
             "Could not find distribution %s" % err)
 
@@ -147,7 +147,7 @@
         try:
             distroseries, pocket = distribution.getDistroSeriesAndPocket(
                 suite)
-        except NotFoundError, err:
+        except NotFoundError as err:
             raise PackageLocationError(
                 "Could not find suite %s" % err)
     else:
@@ -161,7 +161,7 @@
             try:
                 packageset = packageset_set.getByName(
                     packageset_name, distroseries=distroseries)
-            except NotFoundError, err:
+            except NotFoundError as err:
                 raise PackageLocationError(
                     "Could not find packageset %s" % err)
             packagesets.append(packageset)

=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py	2012-06-28 14:45:12 +0000
+++ lib/lp/soyuz/browser/archive.py	2012-06-29 08:46:59 +0000
@@ -1435,7 +1435,7 @@
                     dest_display_name=dest_display_name, person=person,
                     check_permissions=check_permissions,
                     sponsored=sponsored_person)
-        except CannotCopy, error:
+        except CannotCopy as error:
             self.setFieldError(
                 sources_field_name, render_cannotcopy_as_html(error))
             return False

=== modified file 'lib/lp/soyuz/browser/queue.py'
--- lib/lp/soyuz/browser/queue.py	2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/browser/queue.py	2012-06-29 08:46:59 +0000
@@ -388,7 +388,7 @@
                 binary_overridden = queue_item.overrideBinaries(
                     new_component, new_section, new_priority,
                     allowed_components)
-            except QueueInconsistentStateError, info:
+            except QueueInconsistentStateError as info:
                 failure.append("FAILED: %s (%s)" %
                                (queue_item.displayname, info))
                 continue
@@ -409,7 +409,7 @@
 
             try:
                 getattr(self, 'queue_action_' + action)(queue_item)
-            except QueueInconsistentStateError, info:
+            except QueueInconsistentStateError as info:
                 failure.append('FAILED: %s (%s)' %
                                (queue_item.displayname, info))
             else:

=== modified file 'lib/lp/soyuz/doc/distroseriesqueue.txt'
--- lib/lp/soyuz/doc/distroseriesqueue.txt	2012-01-06 11:08:30 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue.txt	2012-06-29 08:46:59 +0000
@@ -97,7 +97,7 @@
     ...     try:
     ...         item.setAccepted()
     ...         item.syncUpdate()
-    ...     except QueueInconsistentStateError, info:
+    ...     except QueueInconsistentStateError as info:
     ...         print info
 
     >>> accepted_queue = hoary.getPackageUploads(PackageUploadStatus.ACCEPTED)
@@ -308,7 +308,7 @@
     >>> for item in items:
     ...      try:
     ...          item.setAccepted()
-    ...      except QueueInconsistentStateError, e:
+    ...      except QueueInconsistentStateError as e:
     ...          print item.displayname, e
     ...      else:
     ...          print item.displayname, item.status.name
@@ -339,7 +339,7 @@
     >>> for item in items:
     ...      try:
     ...          item.setNew()
-    ...      except QueueInconsistentStateError, e:
+    ...      except QueueInconsistentStateError as e:
     ...          print item.displayname, e
     ...      else:
     ...          print item.displayname, 'BOGUS'
@@ -380,7 +380,7 @@
     >>> naked_bin.component = getUtility(IComponentSet).new('hell')
     >>> try:
     ...     item.setAccepted()
-    ... except QueueInconsistentStateError, e:
+    ... except QueueInconsistentStateError as e:
     ...     print item.displayname, e
     ... else:
     ...     print item.displayname, 'ACCEPTED'
@@ -839,7 +839,7 @@
     >>> insertFakeChangesFile(items[3].changesfile.id)
     >>> try:
     ...    items[1].acceptFromQueue()
-    ... except QueueInconsistentStateError, e:
+    ... except QueueInconsistentStateError as e:
     ...    print 'FAILED'
     ... else:
     ...    print 'DONE'
@@ -870,7 +870,7 @@
 
     >>> try:
     ...     items[3].rejectFromQueue()
-    ... except QueueInconsistentStateError, e:
+    ... except QueueInconsistentStateError as e:
     ...    print 'FAILED'
     ... else:
     ...    print 'REJECTED'

=== modified file 'lib/lp/soyuz/doc/manage-chroot.txt'
--- lib/lp/soyuz/doc/manage-chroot.txt	2012-01-19 03:09:09 +0000
+++ lib/lp/soyuz/doc/manage-chroot.txt	2012-06-29 08:46:59 +0000
@@ -86,7 +86,7 @@
     >>> manage_chroot = getScriptObject("bogus")
     >>> try:
     ...      manage_chroot.mainTask()
-    ... except SoyuzScriptError, info:
+    ... except SoyuzScriptError as info:
     ...     print info
     ... else:
     ...     print "Did not get expected exception"
@@ -99,7 +99,7 @@
     >>> manage_chroot = getScriptObject("add", arch="bogus")
     >>> try:
     ...      manage_chroot.mainTask()
-    ... except SoyuzScriptError, info:
+    ... except SoyuzScriptError as info:
     ...     print info
     ... else:
     ...     print "Did not get expected exception"
@@ -125,7 +125,7 @@
     >>> manage_chroot = getScriptObject("add", filepath=filepath)
     >>> try:
     ...      manage_chroot.mainTask()
-    ... except SoyuzScriptError, info:
+    ... except SoyuzScriptError as info:
     ...     print info
     ... else:
     ...     print "Did not get expected exception"
@@ -171,7 +171,7 @@
     >>> manage_chroot = getScriptObject("get", filepath=filepath)
     >>> try:
     ...      manage_chroot.mainTask()
-    ... except SoyuzScriptError, info:
+    ... except SoyuzScriptError as info:
     ...     print info
     ... else:
     ...     print "Did not get expected exception"
@@ -190,7 +190,7 @@
     >>> manage_chroot = getScriptObject("add", filepath=filepath)
     >>> try:
     ...      manage_chroot.mainTask()
-    ... except SoyuzScriptError, info:
+    ... except SoyuzScriptError as info:
     ...     print info
     ... else:
     ...     print "Did not get expected exception"

=== modified file 'lib/lp/soyuz/doc/soyuz-upload.txt'
--- lib/lp/soyuz/doc/soyuz-upload.txt	2012-04-17 08:32:44 +0000
+++ lib/lp/soyuz/doc/soyuz-upload.txt	2012-06-29 08:46:59 +0000
@@ -405,7 +405,7 @@
     >>> for queue_item in queue_items:
     ...      try:
     ...          queue_item.setAccepted()
-    ...      except QueueInconsistentStateError, e:
+    ...      except QueueInconsistentStateError as e:
     ...          L.append("%s %s" % (queue_item.sourcepackagerelease.name, e))
     ...      else:
     ...          L.append("%s %s" % (queue_item.sourcepackagerelease.name,

=== modified file 'lib/lp/soyuz/model/binarypackagebuild.py'
--- lib/lp/soyuz/model/binarypackagebuild.py	2012-06-19 03:26:57 +0000
+++ lib/lp/soyuz/model/binarypackagebuild.py	2012-06-29 08:46:59 +0000
@@ -855,7 +855,7 @@
         """See `IBinaryPackageBuildSet`."""
         try:
             return BinaryPackageBuild.get(id)
-        except SQLObjectNotFound, e:
+        except SQLObjectNotFound as e:
             raise NotFoundError(str(e))
 
     def getByBuildFarmJob(self, build_farm_job):
@@ -1179,7 +1179,7 @@
             build = IMasterObject(build)
             try:
                 build.updateDependencies()
-            except UnparsableDependencies, e:
+            except UnparsableDependencies as e:
                 logger.error(e)
                 continue
 

=== modified file 'lib/lp/soyuz/model/packagecopyjob.py'
--- lib/lp/soyuz/model/packagecopyjob.py	2012-06-28 12:21:01 +0000
+++ lib/lp/soyuz/model/packagecopyjob.py	2012-06-29 08:46:59 +0000
@@ -493,7 +493,7 @@
         """See `IRunnableJob`."""
         try:
             self.attemptCopy()
-        except CannotCopy, e:
+        except CannotCopy as e:
             logger = logging.getLogger()
             logger.info("Job:\n%s\nraised CannotCopy:\n%s" % (self, e))
             self.abort()  # Abort the txn.

=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py	2012-06-19 16:09:38 +0000
+++ lib/lp/soyuz/model/publishing.py	2012-06-29 08:46:59 +0000
@@ -313,7 +313,7 @@
         try:
             for pub_file in self.files:
                 pub_file.publish(diskpool, log)
-        except PoolFileOverwriteError, e:
+        except PoolFileOverwriteError as e:
             message = "PoolFileOverwriteError: %s, skipping." % e
             properties = [('error-explanation', message)]
             request = ScriptRequest(properties)

=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py	2012-06-19 03:26:57 +0000
+++ lib/lp/soyuz/model/queue.py	2012-06-29 08:46:59 +0000
@@ -293,7 +293,7 @@
             # Mask the error with state-machine default exception
             try:
                 source.checkComponentAndSection()
-            except QueueSourceAcceptError, info:
+            except QueueSourceAcceptError as info:
                 raise QueueInconsistentStateError(info)
 
         self._checkForBinariesinDestinationArchive(
@@ -301,7 +301,7 @@
         for queue_build in self.builds:
             try:
                 queue_build.checkComponentAndSection()
-            except QueueBuildAcceptError, info:
+            except QueueBuildAcceptError as info:
                 raise QueueInconsistentStateError(info)
 
         # if the previous checks applied and pass we do set the value
@@ -754,7 +754,7 @@
         for customfile in self.customfiles:
             try:
                 customfile.publish(logger)
-            except CustomUploadError, e:
+            except CustomUploadError as e:
                 if logger is not None:
                     logger.error("Queue item ignored: %s" % e)
                     return []

=== modified file 'lib/lp/soyuz/scripts/add_missing_builds.py'
--- lib/lp/soyuz/scripts/add_missing_builds.py	2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/scripts/add_missing_builds.py	2012-06-29 08:46:59 +0000
@@ -87,7 +87,7 @@
         """Entry point for `LaunchpadScript`s."""
         try:
             self.setupLocation()
-        except SoyuzScriptError, err:
+        except SoyuzScriptError as err:
             raise LaunchpadScriptFailure(err)
 
         if not self.options.arch_tags:
@@ -113,7 +113,7 @@
                 self.location.distroseries, self.location.pocket)
             self.txn.commit()
             self.logger.info("Finished adding builds.")
-        except Exception, err:
+        except Exception as err:
             self.logger.error(err)
             self.txn.abort()
             self.logger.info("Errors, aborted transaction.")

=== modified file 'lib/lp/soyuz/scripts/buildd.py'
--- lib/lp/soyuz/scripts/buildd.py	2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/scripts/buildd.py	2012-06-29 08:46:59 +0000
@@ -211,7 +211,7 @@
             try:
                 distroseries, pocket = distribution.getDistroSeriesAndPocket(
                     suite)
-            except NotFoundError, err:
+            except NotFoundError as err:
                 raise LaunchpadScriptFailure("Could not find suite %s" % err)
             distroseries_set.add(distroseries)
 

=== modified file 'lib/lp/soyuz/scripts/chrootmanager.py'
--- lib/lp/soyuz/scripts/chrootmanager.py	2012-01-19 03:06:04 +0000
+++ lib/lp/soyuz/scripts/chrootmanager.py	2012-06-29 08:46:59 +0000
@@ -71,7 +71,7 @@
         try:
             alias_id = getUtility(ILibrarianClient).addFile(
                 filename, flen, fd, contentType=ftype)
-        except UploadFailed, info:
+        except UploadFailed as info:
             raise ChrootManagerError("Librarian upload failed: %s" % info)
 
         lfa = getUtility(ILibraryFileAliasSet)[alias_id]
@@ -201,7 +201,7 @@
 
         try:
             distroarchseries = series[self.options.architecture]
-        except NotFoundError, info:
+        except NotFoundError as info:
             raise SoyuzScriptError("Architecture not found: %s" % info)
 
         # We don't want to have to force the user to confirm transactions
@@ -222,7 +222,7 @@
 
         try:
             chroot_action()
-        except ChrootManagerError, info:
+        except ChrootManagerError as info:
             raise SoyuzScriptError(info)
         else:
             # Collect extra debug messages from chroot_manager.

=== modified file 'lib/lp/soyuz/scripts/ftpmasterbase.py'
--- lib/lp/soyuz/scripts/ftpmasterbase.py	2012-06-19 17:32:05 +0000
+++ lib/lp/soyuz/scripts/ftpmasterbase.py	2012-06-29 08:46:59 +0000
@@ -131,7 +131,7 @@
         try:
             desired_component = getUtility(IComponentSet)[
                 self.options.component]
-        except NotFoundError, err:
+        except NotFoundError as err:
             raise SoyuzScriptError(err)
 
         if currently_published.component != desired_component:
@@ -253,7 +253,7 @@
         try:
             self.setupLocation()
             self.mainTask()
-        except SoyuzScriptError, err:
+        except SoyuzScriptError as err:
             raise LaunchpadScriptFailure(err)
 
         self.finishProcedure()

=== modified file 'lib/lp/soyuz/scripts/gina/packages.py'
--- lib/lp/soyuz/scripts/gina/packages.py	2012-06-19 22:53:13 +0000
+++ lib/lp/soyuz/scripts/gina/packages.py	2012-06-29 08:46:59 +0000
@@ -105,7 +105,7 @@
                                                  component, archive_root)
     try:
         extract_dpkg_source(dsc_path, ".", vendor=distro_name)
-    except DpkgSourceError, e:
+    except DpkgSourceError as e:
         raise ExecutionError("Error %d unpacking source" % e.result)
 
     version = re.sub("^\d+:", "", version)

=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
--- lib/lp/soyuz/scripts/initialize_distroseries.py	2012-04-23 01:06:55 +0000
+++ lib/lp/soyuz/scripts/initialize_distroseries.py	2012-06-29 08:46:59 +0000
@@ -569,7 +569,7 @@
                                    list(self.distroseries.architectures))
                                 rebuilds.extend(builds)
                             self._rescore_rebuilds(rebuilds)
-                    except CannotCopy, error:
+                    except CannotCopy as error:
                         raise InitializationError(error)
 
     def _rescore_rebuilds(self, builds):

=== modified file 'lib/lp/soyuz/scripts/packagecopier.py'
--- lib/lp/soyuz/scripts/packagecopier.py	2012-06-29 01:03:10 +0000
+++ lib/lp/soyuz/scripts/packagecopier.py	2012-06-29 08:46:59 +0000
@@ -639,7 +639,7 @@
         try:
             copy_checker.checkCopy(
                 source, destination_series, pocket, person, check_permissions)
-        except CannotCopy, reason:
+        except CannotCopy as reason:
             errors.append("%s (%s)" % (source.displayname, reason))
             continue
 
@@ -1057,7 +1057,7 @@
                 self.options.include_binaries, allow_delayed_copies=False,
                 check_permissions=False, unembargo=self.options.unembargo,
                 logger=self.logger)
-        except CannotCopy, error:
+        except CannotCopy as error:
             self.logger.error(str(error))
             return []
 

=== modified file 'lib/lp/soyuz/scripts/publishdistro.py'
--- lib/lp/soyuz/scripts/publishdistro.py	2011-08-08 07:31:08 +0000
+++ lib/lp/soyuz/scripts/publishdistro.py	2012-06-29 08:46:59 +0000
@@ -220,7 +220,7 @@
         """
         try:
             series, pocket = distribution.getDistroSeriesAndPocket(suite)
-        except NotFoundError, e:
+        except NotFoundError as e:
             raise OptionValueError(e)
         return series.name, pocket
 

=== modified file 'lib/lp/soyuz/scripts/querydistro.py'
--- lib/lp/soyuz/scripts/querydistro.py	2012-06-20 01:19:03 +0000
+++ lib/lp/soyuz/scripts/querydistro.py	2012-06-29 08:46:59 +0000
@@ -58,7 +58,7 @@
             self.location = build_package_location(
                 distribution_name=self.options.distribution_name,
                 suite=self.options.suite)
-        except PackageLocationError, err:
+        except PackageLocationError as err:
             raise LaunchpadScriptFailure(err)
 
     def defaultPresenter(self, result):

=== modified file 'lib/lp/soyuz/scripts/queue.py'
--- lib/lp/soyuz/scripts/queue.py	2012-02-10 10:50:03 +0000
+++ lib/lp/soyuz/scripts/queue.py	2012-06-29 08:46:59 +0000
@@ -167,7 +167,7 @@
                 # retrieve PackageUpload item by id
                 try:
                     item = getUtility(IPackageUploadSet).get(int(term))
-                except NotFoundError, info:
+                except NotFoundError as info:
                     raise QueueActionError('Queue Item not found: %s' % info)
 
                 if item.status != self.queue:
@@ -429,7 +429,7 @@
                 # do not overwrite files on disk (bug # 62976)
                 try:
                     existing_file = open(libfile.filename, "r")
-                except IOError, e:
+                except IOError as e:
                     if not e.errno == errno.ENOENT:
                         raise
                     # File does not already exist, so read file from librarian
@@ -477,7 +477,7 @@
             try:
                 queue_item.rejectFromQueue(
                     logger=self.log, dry_run=self.no_mail)
-            except QueueInconsistentStateError, info:
+            except QueueInconsistentStateError as info:
                 self.display('** %s could not be rejected due %s'
                              % (queue_item.displayname, info))
 
@@ -502,7 +502,7 @@
             try:
                 queue_item.acceptFromQueue(
                     logger=self.log, dry_run=self.no_mail)
-            except QueueInconsistentStateError, info:
+            except QueueInconsistentStateError as info:
                 self.display('** %s could not be accepted due to %s'
                              % (queue_item.displayname, info))
                 continue
@@ -586,7 +586,7 @@
                 component = getUtility(IComponentSet)[self.component_name]
             if self.section_name:
                 section = getUtility(ISectionSet)[self.section_name]
-        except NotFoundError, info:
+        except NotFoundError as info:
             raise QueueActionError('Not Found: %s' % info)
 
         for queue_item in self.items:
@@ -620,7 +620,7 @@
                 section = getUtility(ISectionSet)[self.section_name]
             if self.priority_name:
                 priority = name_priority_map[self.priority_name]
-        except (NotFoundError, KeyError), info:
+        except (NotFoundError, KeyError) as info:
             raise QueueActionError('Not Found: %s' % info)
 
         overridden = []
@@ -731,7 +731,7 @@
                 log=self.log)
             queue_action.initialize()
             queue_action.run()
-        except QueueActionError, info:
+        except QueueActionError as info:
             raise CommandRunnerError(info)
 
         return queue_action

=== modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py'
--- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2012-04-23 17:54:25 +0000
+++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2012-06-29 08:46:59 +0000
@@ -945,7 +945,7 @@
             switch_dbuser(user)
             try:
                 create_job(derived, packages[user], parent)
-            except ProgrammingError, e:
+            except ProgrammingError as e:
                 self.assertTrue(
                     False,
                     "Database role %s was unable to create a job.  "

=== modified file 'lib/lp/testing/browser.py'
--- lib/lp/testing/browser.py	2011-12-22 05:09:10 +0000
+++ lib/lp/testing/browser.py	2012-06-29 08:46:59 +0000
@@ -118,7 +118,7 @@
         try:
             self.mech_browser.submit(id=control.id, name=control.name,
                 label=label, coord=coord)
-        except Exception, e:
+        except Exception as e:
             fix_exception_name(e)
             raise
         self._stop_timer()

=== modified file 'lib/lp/testing/keyserver/web.py'
--- lib/lp/testing/keyserver/web.py	2011-12-09 00:20:44 +0000
+++ lib/lp/testing/keyserver/web.py	2012-06-29 08:46:59 +0000
@@ -198,7 +198,7 @@
         try:
             key = gpghandler.importPublicKey(keytext)
         except (GPGKeyNotFoundError, SecretGPGKeyImportDetected,
-                MoreThanOneGPGKeyFound), err:
+                MoreThanOneGPGKeyFound) as err:
             return SUBMIT_KEY_PAGE % {'banner': str(err)}
 
         filename = '0x%s.get' % key.fingerprint

=== modified file 'lib/lp/testing/layers.py'
--- lib/lp/testing/layers.py	2012-06-14 05:18:22 +0000
+++ lib/lp/testing/layers.py	2012-06-29 08:46:59 +0000
@@ -245,7 +245,7 @@
     while True:
         try:
             os.waitpid(-1, os.WNOHANG)
-        except OSError, error:
+        except OSError as error:
             if error.errno != errno.ECHILD:
                 raise
             break
@@ -868,7 +868,7 @@
         try:
             f = urlopen(config.librarian.download_url)
             f.read()
-        except Exception, e:
+        except Exception as e:
             raise LayerIsolationError(
                     "Librarian has been killed or has hung."
                     "Tests should use LibrarianLayer.hide() and "
@@ -1714,7 +1714,7 @@
         """
         try:
             os.kill(cls.appserver.pid, sig)
-        except OSError, error:
+        except OSError as error:
             if error.errno == errno.ESRCH:
                 # The child process doesn't exist.  Maybe it went away by the
                 # time we got here.
@@ -1777,7 +1777,7 @@
             # Don't worry if the process no longer exists.
             try:
                 os.kill(pid, signal.SIGTERM)
-            except OSError, error:
+            except OSError as error:
                 if error.errno != errno.ESRCH:
                     raise
             pidfile.remove_pidfile('launchpad', cls.appserver_config)
@@ -1809,7 +1809,7 @@
             try:
                 connection = urlopen(root_url)
                 connection.read()
-            except IOError, error:
+            except IOError as error:
                 # We are interested in a wrapped socket.error.
                 # urlopen() really sucks here.
                 if len(error.args) <= 1:

=== modified file 'lib/lp/testing/matchers.py'
--- lib/lp/testing/matchers.py	2011-12-24 17:49:30 +0000
+++ lib/lp/testing/matchers.py	2012-06-29 08:46:59 +0000
@@ -156,7 +156,7 @@
             if not verifyObject(self.interface, matchee):
                 passed = False
         except (BrokenImplementation, BrokenMethodImplementation,
-                DoesNotImplement), e:
+                DoesNotImplement) as e:
             passed = False
             extra = str(e)
         if not passed:

=== modified file 'lib/lp/testing/pgsql.py'
--- lib/lp/testing/pgsql.py	2011-12-30 06:14:56 +0000
+++ lib/lp/testing/pgsql.py	2012-06-29 08:46:59 +0000
@@ -338,7 +338,7 @@
                                     "create db in %0.2fs\n" % (
                                         time.time() - _start))
                             break
-                        except psycopg2.DatabaseError, x:
+                        except psycopg2.DatabaseError as x:
                             if counter == attempts - 1:
                                 raise
                             x = str(x)
@@ -403,7 +403,7 @@
         for i in range(0, attempts):
             try:
                 con = self.superuser_connection(self.template)
-            except psycopg2.OperationalError, x:
+            except psycopg2.OperationalError as x:
                 if 'does not exist' in str(x):
                     return
                 raise
@@ -428,7 +428,7 @@
                 try:
                     cur = con.cursor()
                     cur.execute('DROP DATABASE %s' % self.dbname)
-                except psycopg2.DatabaseError, x:
+                except psycopg2.DatabaseError as x:
                     if i == attempts - 1:
                         # Too many failures - raise an exception
                         raise

=== modified file 'lib/lp/testing/tests/test_matchers.py'
--- lib/lp/testing/tests/test_matchers.py	2012-01-01 02:58:52 +0000
+++ lib/lp/testing/tests/test_matchers.py	2012-06-29 08:46:59 +0000
@@ -137,7 +137,7 @@
         try:
             verifyObject(ITestInterface, obj)
             self.assert_("verifyObject did not raise an exception.")
-        except BrokenImplementation, e:
+        except BrokenImplementation as e:
             extra = str(e)
         self.assertEqual(extra, mismatch.extra)
 

=== modified file 'lib/lp/translations/browser/language.py'
--- lib/lp/translations/browser/language.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/browser/language.py	2012-06-29 08:46:59 +0000
@@ -327,7 +327,7 @@
         """Validate plural expression and number of plural forms."""
         try:
             make_friendly_plural_forms(pluralexpression, pluralforms)
-        except BadPluralExpression, e:
+        except BadPluralExpression as e:
             self.setFieldError('pluralexpression', str(e))
 
     def validate(self, data):

=== modified file 'lib/lp/translations/browser/tests/distroseries-views.txt'
--- lib/lp/translations/browser/tests/distroseries-views.txt	2012-04-10 14:01:17 +0000
+++ lib/lp/translations/browser/tests/distroseries-views.txt	2012-06-29 08:46:59 +0000
@@ -40,7 +40,7 @@
     ...
     ...     try:
     ...         view.checkTranslationsViewable()
-    ...     except TranslationUnavailable, message:
+    ...     except TranslationUnavailable as message:
     ...         return unicode(message)
     ...     return None
 

=== modified file 'lib/lp/translations/browser/translationmessage.py'
--- lib/lp/translations/browser/translationmessage.py	2012-02-17 07:43:40 +0000
+++ lib/lp/translations/browser/translationmessage.py	2012-06-29 08:46:59 +0000
@@ -454,7 +454,7 @@
         """
         try:
             self._storeTranslations(potmsgset)
-        except GettextValidationError, e:
+        except GettextValidationError as e:
             return unicode(e)
         except TranslationConflict:
             # The translations are demoted to suggestions, but they may

=== modified file 'lib/lp/translations/model/pofile.py'
--- lib/lp/translations/model/pofile.py	2012-02-15 21:14:05 +0000
+++ lib/lp/translations/model/pofile.py	2012-06-29 08:46:59 +0000
@@ -1044,7 +1044,7 @@
             entry_to_import.setErrorOutput(
                 "File was not exported from Launchpad.")
         except (MixedNewlineMarkersError, TranslationFormatSyntaxError,
-                TranslationFormatInvalidInputError, UnicodeDecodeError), (
+                TranslationFormatInvalidInputError, UnicodeDecodeError) as (
                 exception):
             # The import failed with a format error. We log it and select the
             # email template.
@@ -1059,7 +1059,7 @@
             error_text = str(exception)
             entry_to_import.setErrorOutput(error_text)
             needs_notification_for_imported = True
-        except OutdatedTranslationError, exception:
+        except OutdatedTranslationError as exception:
             # The attached file is older than the last imported one, we ignore
             # it. We also log this problem and select the email template.
             if logger:

=== modified file 'lib/lp/translations/model/potemplate.py'
--- lib/lp/translations/model/potemplate.py	2011-12-30 06:14:56 +0000
+++ lib/lp/translations/model/potemplate.py	2012-06-29 08:46:59 +0000
@@ -941,7 +941,7 @@
             errors, warnings = translation_importer.importFile(
                 entry_to_import, logger)
         except (MixedNewlineMarkersError, TranslationFormatSyntaxError,
-                TranslationFormatInvalidInputError, UnicodeDecodeError), (
+                TranslationFormatInvalidInputError, UnicodeDecodeError) as (
                 exception):
             if logger:
                 logger.info(
@@ -1005,7 +1005,7 @@
                     if txn is not None:
                         txn.commit()
                         txn.begin()
-                except TransactionRollbackError, error:
+                except TransactionRollbackError as error:
                     if txn is not None:
                         txn.abort()
                         txn.begin()

=== modified file 'lib/lp/translations/model/translationtemplatesbuildjob.py'
--- lib/lp/translations/model/translationtemplatesbuildjob.py	2012-01-02 11:21:14 +0000
+++ lib/lp/translations/model/translationtemplatesbuildjob.py	2012-06-29 08:46:59 +0000
@@ -209,7 +209,7 @@
                     "Requesting templates build for branch %s.",
                     branch.unique_name)
                 cls.create(branch)
-        except Exception, e:
+        except Exception as e:
             logger.error(e)
             raise
 

=== modified file 'lib/lp/translations/scripts/copy_distroseries_translations.py'
--- lib/lp/translations/scripts/copy_distroseries_translations.py	2010-08-20 20:31:18 +0000
+++ lib/lp/translations/scripts/copy_distroseries_translations.py	2012-06-29 08:46:59 +0000
@@ -101,7 +101,7 @@
     finally:
         try:
             statekeeper.restore()
-        except Warning, message:
+        except Warning as message:
             logger.warning(message)
         except:
             logger.warning(

=== modified file 'lib/lp/translations/scripts/gettext_check_messages.py'
--- lib/lp/translations/scripts/gettext_check_messages.py	2010-12-02 16:13:51 +0000
+++ lib/lp/translations/scripts/gettext_check_messages.py	2012-06-29 08:46:59 +0000
@@ -100,7 +100,7 @@
             validate_translation(
                 potmsgset.singular_text, potmsgset.plural_text,
                 msgstrs, potmsgset.flags)
-        except GettextValidationError, error:
+        except GettextValidationError as error:
             self._error_count += 1
             return unicode(error)
 

=== modified file 'lib/lp/translations/scripts/language_pack.py'
--- lib/lp/translations/scripts/language_pack.py	2011-12-30 06:14:56 +0000
+++ lib/lp/translations/scripts/language_pack.py	2012-06-29 08:46:59 +0000
@@ -281,7 +281,7 @@
                 size=size,
                 file=filehandle,
                 contentType='application/x-gtar')
-        except UploadFailed, e:
+        except UploadFailed as e:
             logger.error('Uploading to the Librarian failed: %s', e)
             return None
         except:

=== modified file 'lib/lp/translations/scripts/po_import.py'
--- lib/lp/translations/scripts/po_import.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/scripts/po_import.py	2012-06-29 08:46:59 +0000
@@ -191,10 +191,10 @@
                         self.txn.commit()
                 except KeyboardInterrupt:
                     raise
-                except (AssertionError, SystemError), e:
+                except (AssertionError, SystemError) as e:
                     self._registerFailure(entry, e, abort=True)
                     raise
-                except Exception, e:
+                except Exception as e:
                     if self.txn:
                         self.txn.abort()
                     self._registerFailure(entry, e, traceback=True)

=== modified file 'lib/lp/translations/scripts/validate_translations_file.py'
--- lib/lp/translations/scripts/validate_translations_file.py	2011-12-21 20:23:01 +0000
+++ lib/lp/translations/scripts/validate_translations_file.py	2012-06-29 08:46:59 +0000
@@ -116,7 +116,7 @@
             raise
         except UnknownFileType:
             raise
-        except Exception, e:
+        except Exception as e:
             self.logger.warn("Failure in '%s': %s" % (filename, e))
             return False
 

=== modified file 'lib/lp/translations/scripts/verify_pofile_stats.py'
--- lib/lp/translations/scripts/verify_pofile_stats.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/scripts/verify_pofile_stats.py	2012-06-29 08:46:59 +0000
@@ -75,7 +75,7 @@
                 self._verify(pofile)
             except (KeyboardInterrupt, SystemExit):
                 raise
-            except Exception, error:
+            except Exception as error:
                 # Verification failed for this POFile.  Don't bail out: if
                 # there's a pattern of failure, we'll want to report that and
                 # not just the first problem we encounter.

=== modified file 'lib/lp/translations/stories/translationgroups/xx-link-to-documentation.txt'
--- lib/lp/translations/stories/translationgroups/xx-link-to-documentation.txt	2012-06-16 21:13:24 +0000
+++ lib/lp/translations/stories/translationgroups/xx-link-to-documentation.txt	2012-06-29 08:46:59 +0000
@@ -70,7 +70,7 @@
     ...     test_browser.open(
     ...         'http://translations.launchpad.dev/'
     ...         '+groups/testing-translation-team/eo/+admin')
-    ... except Unauthorized, e:
+    ... except Unauthorized as e:
     ...     print e
     (...'launchpad.Admin')
     >>> test_browser.open(

=== modified file 'lib/lp/translations/tests/test_pottery_detect_intltool.py'
--- lib/lp/translations/tests/test_pottery_detect_intltool.py	2011-12-21 19:25:05 +0000
+++ lib/lp/translations/tests/test_pottery_detect_intltool.py	2012-06-29 08:46:59 +0000
@@ -56,7 +56,7 @@
             if directory != '':
                 try:
                     os.makedirs(directory)
-                except OSError, e:
+                except OSError as e:
                     # Doesn't matter if it already exists.
                     if e.errno != 17:
                         raise

=== modified file 'lib/lp/translations/utilities/gettext_po_parser.py'
--- lib/lp/translations/utilities/gettext_po_parser.py	2011-06-09 10:50:25 +0000
+++ lib/lp/translations/utilities/gettext_po_parser.py	2012-06-29 08:46:59 +0000
@@ -228,7 +228,7 @@
         """Attempt to parse `date_string`, or return None if invalid."""
         try:
             return zope_datetime.parseDatetimetz(date_string)
-        except (ValueError, zope_datetime.DateTimeError), exception:
+        except (ValueError, zope_datetime.DateTimeError) as exception:
             return None
 
     def _parseHeaderFields(self):
@@ -478,7 +478,7 @@
         # decode as many characters as we can:
         try:
             newchars, length = decode(self._pending_chars, 'strict')
-        except UnicodeDecodeError, exc:
+        except UnicodeDecodeError as exc:
             # XXX: James Henstridge 2006-03-16:
             # If the number of unconvertable chars is longer than a
             # multibyte sequence to be, the UnicodeDecodeError indicates
@@ -619,7 +619,7 @@
             header = POHeader(header_text, header_comment)
             self._translation_file.header = header
             self._translation_file.syntax_warnings += header.syntax_warnings
-        except TranslationFormatInvalidInputError, error:
+        except TranslationFormatInvalidInputError as error:
             if error.line_number is None:
                 error.line_number = self._message_lineno
             raise

=== modified file 'lib/lp/translations/utilities/mozilla_xpi_importer.py'
--- lib/lp/translations/utilities/mozilla_xpi_importer.py	2012-05-24 20:25:54 +0000
+++ lib/lp/translations/utilities/mozilla_xpi_importer.py	2012-06-29 08:46:59 +0000
@@ -229,7 +229,7 @@
             try:
                 string = line.encode('raw-unicode_escape')
                 line = string.decode('unicode_escape')
-            except UnicodeDecodeError, exception:
+            except UnicodeDecodeError as exception:
                 raise TranslationFormatInvalidInputError(
                     filename=self.filename, line_number=line_num,
                     message=str(exception))

=== modified file 'lib/lp/translations/utilities/mozilla_zip.py'
--- lib/lp/translations/utilities/mozilla_zip.py	2010-08-20 20:31:18 +0000
+++ lib/lp/translations/utilities/mozilla_zip.py	2012-06-29 08:46:59 +0000
@@ -53,7 +53,7 @@
         self.manifest = manifest
         try:
             self.archive = ZipFile(archive, 'r')
-        except BadZipfile, exception:
+        except BadZipfile as exception:
             raise TranslationFormatInvalidInputError(
                 filename=filename, message=str(exception))
 

=== modified file 'lib/lp/translations/utilities/pluralforms.py'
--- lib/lp/translations/utilities/pluralforms.py	2010-08-20 20:31:18 +0000
+++ lib/lp/translations/utilities/pluralforms.py	2012-06-29 08:46:59 +0000
@@ -74,7 +74,7 @@
 
     try:
         function = gettext.c2py(expression)
-    except (ValueError, SyntaxError), e:
+    except (ValueError, SyntaxError) as e:
         raise BadPluralExpression(e.args[0])
 
     return function

=== modified file 'lib/lp/translations/utilities/tests/test_gettext_po_parser.py'
--- lib/lp/translations/utilities/tests/test_gettext_po_parser.py	2010-08-20 20:31:18 +0000
+++ lib/lp/translations/utilities/tests/test_gettext_po_parser.py	2012-06-29 08:46:59 +0000
@@ -36,7 +36,7 @@
             self.assertTrue(
                 False,
                 "Importing an empty file succeeded; it should have failed.")
-        except TranslationFormatSyntaxError, exception:
+        except TranslationFormatSyntaxError as exception:
             message = exception.represent("Default error message!")
 
         self.assertEqual(message, "File contains no messages.")

=== modified file 'lib/lp/translations/utilities/tests/test_translation_message_data.py'
--- lib/lp/translations/utilities/tests/test_translation_message_data.py	2011-08-12 11:37:08 +0000
+++ lib/lp/translations/utilities/tests/test_translation_message_data.py	2012-06-29 08:46:59 +0000
@@ -70,7 +70,7 @@
         data.addTranslation(0, 'singular')
         try:
             data.addTranslation(0, 'ralugnis')
-        except TranslationFormatSyntaxError, error:
+        except TranslationFormatSyntaxError as error:
             self.assertEqual(
                 error.represent("(Default text, should not be returned.)"),
                 "Message has more than one translation for plural form 0.")

=== modified file 'lib/lp/translations/utilities/translation_import.py'
--- lib/lp/translations/utilities/translation_import.py	2011-12-30 06:14:56 +0000
+++ lib/lp/translations/utilities/translation_import.py	2012-06-29 08:46:59 +0000
@@ -472,7 +472,7 @@
             validate_translation(
                 potmsgset.singular_text, potmsgset.plural_text,
                 translations, potmsgset.flags)
-        except GettextValidationError, e:
+        except GettextValidationError as e:
             self._addUpdateError(message_data, potmsgset, unicode(e))
             message.validation_status = (
                 TranslationValidationStatus.UNKNOWNERROR)

=== modified file 'lib/lp/translations/utilities/validate.py'
--- lib/lp/translations/utilities/validate.py	2010-11-22 14:27:36 +0000
+++ lib/lp/translations/utilities/validate.py	2012-06-29 08:46:59 +0000
@@ -46,6 +46,6 @@
     # Check the msg.
     try:
         msg.check_format()
-    except gettextpo.error, e:
+    except gettextpo.error as e:
         # Wrap gettextpo.error in GettextValidationError.
         raise GettextValidationError(unicode(e))

=== modified file 'lib/lp/translations/utilities/xpi_header.py'
--- lib/lp/translations/utilities/xpi_header.py	2010-08-20 20:31:18 +0000
+++ lib/lp/translations/utilities/xpi_header.py	2012-06-29 08:46:59 +0000
@@ -77,7 +77,7 @@
                     name, email = parseaddr(elem.text)
                     if name != '' and '@' in email:
                         last_name, last_email = name, email
-        except SyntaxError, exception:
+        except SyntaxError as exception:
             raise TranslationFormatSyntaxError(
                 filename='install.rdf', line_number=exception.lineno,
                 message=exception.msg)

=== modified file 'lib/lp/xmlrpc/helpers.py'
--- lib/lp/xmlrpc/helpers.py	2010-08-20 20:31:18 +0000
+++ lib/lp/xmlrpc/helpers.py	2012-06-29 08:46:59 +0000
@@ -19,7 +19,7 @@
     def decorated(*args, **kwargs):
         try:
             return function(*args, **kwargs)
-        except Fault, fault:
+        except Fault as fault:
             return fault
 
     return mergeFunctionMetadata(function, decorated)

=== modified file 'lib/lp_sitecustomize.py'
--- lib/lp_sitecustomize.py	2012-04-12 11:38:44 +0000
+++ lib/lp_sitecustomize.py	2012-06-29 08:46:59 +0000
@@ -165,7 +165,7 @@
         def wrapped_converter(v):
             try:
                 return converter(v)
-            except ValueError, e:
+            except ValueError as e:
                 # Mark the exception as not being OOPS-worthy.
                 alsoProvides(e, IUnloggedException)
                 raise

=== modified file 'scripts/ftpmaster-tools/buildd-mass-retry.py'
--- scripts/ftpmaster-tools/buildd-mass-retry.py	2012-01-01 03:13:08 +0000
+++ scripts/ftpmaster-tools/buildd-mass-retry.py	2012-06-29 08:46:59 +0000
@@ -64,7 +64,7 @@
         try:
             distribution = getUtility(IDistributionSet)[
                 self.options.distribution]
-        except NotFoundError, info:
+        except NotFoundError as info:
             raise LaunchpadScriptFailure("Distribution not found: %s" % info)
 
         try:
@@ -74,7 +74,7 @@
             else:
                 series = distribution.currentseries
                 pocket = PackagePublishingPocket.RELEASE
-        except NotFoundError, info:
+        except NotFoundError as info:
             raise LaunchpadScriptFailure("Suite not found: %s" % info)
 
         # store distroseries as the current IHasBuildRecord provider
@@ -83,7 +83,7 @@
         if self.options.architecture:
             try:
                 dar = series[self.options.architecture]
-            except NotFoundError, info:
+            except NotFoundError as info:
                 raise LaunchpadScriptFailure(info)
 
             # store distroarchseries as the current IHasBuildRecord provider

=== modified file 'scripts/ftpmaster-tools/queue'
--- scripts/ftpmaster-tools/queue	2012-01-01 03:13:08 +0000
+++ scripts/ftpmaster-tools/queue	2012-06-29 08:46:59 +0000
@@ -108,7 +108,7 @@
         for single_args in args_list:
             try:
                 cmd_runner.execute(single_args, self.options.exact_match)
-            except CommandRunnerError, info:
+            except CommandRunnerError as info:
                 print (info)
                 if self.options.ignore_errors:
                     continue

=== modified file 'scripts/script-monitor-nagios.py'
--- scripts/script-monitor-nagios.py	2011-12-30 06:47:17 +0000
+++ scripts/script-monitor-nagios.py	2012-06-29 08:46:59 +0000
@@ -102,7 +102,7 @@
             # Construct our return message
             print "All scripts ran as expected"
             return 0
-    except Exception, e:
+    except Exception as e:
         # Squeeze the exception type and stringification of the exception
         # value on to one line.
         print "Unhandled exception: %s %r" % (e.__class__.__name__, str(e))

=== modified file 'scripts/stop-loggerhead.py'
--- scripts/stop-loggerhead.py	2012-06-27 13:57:04 +0000
+++ scripts/stop-loggerhead.py	2012-06-29 08:46:59 +0000
@@ -18,7 +18,7 @@
 
 try:
     f = open(pidfile, 'r')
-except IOError, e:
+except IOError as e:
     print 'No pid file found.'
     sys.exit(1)
 
@@ -26,7 +26,7 @@
 
 try:
     os.kill(pid, 0)
-except OSError, e:
+except OSError as e:
     print 'Stale pid file; server is not running.'
     sys.exit(1)
 

=== modified file 'test_on_merge.py'
--- test_on_merge.py	2012-01-01 03:20:03 +0000
+++ test_on_merge.py	2012-06-29 08:46:59 +0000
@@ -81,7 +81,7 @@
     cur = con.cursor()
     try:
         cur.execute('drop database launchpad_ftest_template')
-    except psycopg2.ProgrammingError, x:
+    except psycopg2.ProgrammingError as x:
         if 'does not exist' not in str(x):
             raise
 
@@ -196,7 +196,7 @@
             try:
                 rlist, wlist, xlist = select.select(open_readers, [], [], TIMEOUT)
                 break
-            except select.error, e:
+            except select.error as e:
                 # nb: select.error doesn't expose a named 'errno' attribute,
                 # at least in python 2.6.5; see
                 # <http://mail.python.org/pipermail/python-dev/2000-October/009671.html>
@@ -273,7 +273,7 @@
             # Give the processes some time to shut down.
             time.sleep(3)
 
-    except OSError, exc:
+    except OSError as exc:
         if exc.errno == errno.ESRCH:
             # We tried to call os.killpg() and found the group to be empty.
             pass

=== modified file 'utilities/check-configs.py'
--- utilities/check-configs.py	2012-01-01 03:10:25 +0000
+++ utilities/check-configs.py	2012-06-29 08:46:59 +0000
@@ -77,7 +77,7 @@
             try:
                 root, handlers = ZConfig.loadConfig(
                     zconfig_schema, config, arguments)
-            except ZConfig.ConfigurationSyntaxError, error:
+            except ZConfig.ConfigurationSyntaxError as error:
                 if options.verbosity > 2:
                     traceback.print_exc()
                 elif options.verbosity > 1:
@@ -90,7 +90,7 @@
             lazr_config = lazr_schema.load(config)
             try:
                 lazr_config.validate()
-            except ConfigErrors, error:
+            except ConfigErrors as error:
                 if options.verbosity > 2:
                     messages = '\n'.join([str(er) for er in error.errors])
                     print messages

=== modified file 'utilities/check-content-interfaces.py'
--- utilities/check-content-interfaces.py	2012-01-01 03:10:25 +0000
+++ utilities/check-content-interfaces.py	2012-06-29 08:46:59 +0000
@@ -62,11 +62,11 @@
             try:
                 classes_checked += 1
                 result = verifyClass(interface, klass)
-            except BrokenImplementation, e:
+            except BrokenImplementation as e:
                 classes_with_failures += 1
                 print "%s fails to implement %s: missing attribute %s" % (
                     class_name, interface_name, e.name)
-            except BrokenMethodImplementation, e:
+            except BrokenMethodImplementation as e:
                 classes_with_failures += 1
                 print "%s fails to implement %s: invalid method %s: %s" % (
                     class_name, interface_name, e.method, e.mess)

=== modified file 'utilities/community-contributions.py'
--- utilities/community-contributions.py	2012-06-25 14:50:04 +0000
+++ utilities/community-contributions.py	2012-06-29 08:46:59 +0000
@@ -647,7 +647,7 @@
         opts, args = getopt.getopt(sys.argv[1:], '?hq',
                                    ['help', 'usage', 'dry-run', 'draft-run',
                                     'devel=', 'db-devel='])
-    except getopt.GetoptError, e:
+    except getopt.GetoptError as e:
         sys.stderr.write("ERROR: " + str(e) + '\n\n')
         usage()
         sys.exit(1)

=== modified file 'utilities/findimports.py'
--- utilities/findimports.py	2012-01-01 03:10:25 +0000
+++ utilities/findimports.py	2012-06-29 08:46:59 +0000
@@ -325,7 +325,7 @@
         opts, args = getopt.getopt(argv[1:], 'duniah',
                                    ['dot', 'unused', 'all', 'names', 'imports',
                                     'help'])
-    except getopt.error, e:
+    except getopt.error as e:
         print >> sys.stderr, "%s: %s" % (progname, e)
         print >> sys.stderr, "Try %s --help." % progname
         return 1

=== modified file 'utilities/formatdoctest.py'
--- utilities/formatdoctest.py	2012-01-01 03:10:25 +0000
+++ utilities/formatdoctest.py	2012-06-29 08:46:59 +0000
@@ -289,7 +289,7 @@
             return
         try:
             tree = compiler.parse(code)
-        except (SyntaxError, IndentationError), exc:
+        except (SyntaxError, IndentationError) as exc:
             (lineno, offset_, line) = exc[1][1:]
             if line.endswith("\n"):
                 line = line[:-1]

=== modified file 'utilities/link-external-sourcecode'
--- utilities/link-external-sourcecode	2012-01-01 03:10:25 +0000
+++ utilities/link-external-sourcecode	2012-06-29 08:46:59 +0000
@@ -75,7 +75,7 @@
         if islink(destination):
             unlink(destination)
         symlink(source, destination)
-    except OSError, error:
+    except OSError as error:
         stderr.write(
             '  Error linking %s: %s\n' % (basename(destination), error))
     else:

=== modified file 'utilities/pgmassacre.py'
--- utilities/pgmassacre.py	2012-01-01 03:10:25 +0000
+++ utilities/pgmassacre.py	2012-06-29 08:46:59 +0000
@@ -168,7 +168,7 @@
             cur.execute(create_db_cmd)
             con.close()
             return 0
-        except psycopg2.Error, exception:
+        except psycopg2.Error as exception:
             error_msg = str(exception)
         time.sleep(0.6)  # Stats only updated every 500ms.
         now = time.time()

=== modified file 'utilities/tcpwatch/tcpwatch.py'
--- utilities/tcpwatch/tcpwatch.py	2012-01-06 11:08:30 +0000
+++ utilities/tcpwatch/tcpwatch.py	2012-06-29 08:46:59 +0000
@@ -1361,7 +1361,7 @@
                                         'no-record-responses',
                                         'no-record-errors',
                                        ])
-    except getopt.GetoptError, msg:
+    except getopt.GetoptError as msg:
         usageError(msg)
 
     fwd_params = []


Follow ups