Merge lp:~cjwatson/launchpad/new-style-except into lp:launchpad
- new-style-except
- Merge into devel
Proposed by
Colin Watson
on 2012-06-29
| Status: | Merged |
|---|---|
| Approved by: | Colin Watson on 2012-07-02 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 15543 |
| Proposed branch: | lp:~cjwatson/launchpad/new-style-except |
| Merge into: | lp:launchpad |
| Diff against target: |
4563 lines (+437/-436) 217 files modified
buildmailman.py (+2/-2) bzrplugins/lpserve/__init__.py (+7/-7) bzrplugins/lpserve/test_lpserve.py (+5/-5) cronscripts/process-mail.py (+1/-1) cronscripts/publishing/maintenance-check.py (+1/-1) cronscripts/reprocess-hwdb-submissions.py (+1/-1) daemons/cache-database-replication-lag.py (+1/-1) database/replication/new-slave.py (+3/-3) database/schema/full-update.py (+2/-2) ez_setup.py (+1/-1) lib/BeautifulSoup.py (+1/-1) lib/contrib/apachelog.py (+1/-1) lib/contrib/glock.py (+2/-2) lib/launchpad_loggerhead/app.py (+2/-2) lib/lp/app/browser/folder.py (+1/-1) lib/lp/app/browser/launchpad.py (+2/-2) lib/lp/app/browser/tales.py (+1/-1) lib/lp/app/widgets/date.py (+2/-2) lib/lp/app/widgets/image.py (+1/-1) lib/lp/app/widgets/launchpadtarget.py (+1/-1) lib/lp/app/widgets/tests/test_datetime.py (+1/-1) lib/lp/app/widgets/textwidgets.py (+1/-1) lib/lp/archivepublisher/customupload.py (+1/-1) lib/lp/archivepublisher/deathrow.py (+2/-2) lib/lp/archivepublisher/debversion.py (+1/-1) lib/lp/archivepublisher/dist_upgrader.py (+1/-1) lib/lp/archivepublisher/publishing.py (+1/-1) lib/lp/archivepublisher/scripts/generate_extra_overrides.py (+1/-1) lib/lp/archiveuploader/changesfile.py (+3/-3) lib/lp/archiveuploader/dscfile.py (+15/-15) lib/lp/archiveuploader/nascentupload.py (+4/-4) lib/lp/archiveuploader/nascentuploadfile.py (+2/-2) lib/lp/archiveuploader/tests/test_uploadprocessor.py (+1/-1) lib/lp/archiveuploader/uploadprocessor.py (+6/-6) lib/lp/blueprints/browser/specification.py (+2/-2) lib/lp/bugs/adapters/treelookup.py (+1/-1) lib/lp/bugs/browser/bugalsoaffects.py (+1/-1) lib/lp/bugs/browser/bugtarget.py (+1/-1) lib/lp/bugs/browser/widgets/bug.py (+1/-1) lib/lp/bugs/browser/widgets/bugtask.py (+2/-2) lib/lp/bugs/externalbugtracker/base.py (+1/-1) lib/lp/bugs/externalbugtracker/bugzilla.py (+10/-10) lib/lp/bugs/externalbugtracker/mantis.py (+2/-2) lib/lp/bugs/externalbugtracker/rt.py (+3/-3) lib/lp/bugs/externalbugtracker/trac.py (+6/-6) lib/lp/bugs/externalbugtracker/xmlrpc.py (+1/-1) lib/lp/bugs/mail/commands.py (+2/-2) lib/lp/bugs/mail/handler.py (+2/-2) lib/lp/bugs/model/bug.py (+1/-1) lib/lp/bugs/model/bugtask.py (+1/-1) lib/lp/bugs/model/bugwatch.py (+1/-1) lib/lp/bugs/scripts/bugimport.py (+1/-1) lib/lp/bugs/scripts/bzremotecomponentfinder.py (+1/-1) lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py (+1/-1) lib/lp/bugs/scripts/checkwatches/core.py (+3/-3) lib/lp/bugs/scripts/checkwatches/remotebugupdater.py (+3/-3) lib/lp/bugs/scripts/debbugs.py (+5/-5) lib/lp/bugs/scripts/sfremoteproductfinder.py (+2/-2) lib/lp/bugs/scripts/updateremoteproduct.py (+1/-1) lib/lp/bugs/tests/test_bugwatch.py (+1/-1) lib/lp/bugs/tests/test_duplicate_handling.py (+1/-1) lib/lp/buildmaster/model/builder.py (+1/-1) lib/lp/code/browser/branch.py (+3/-3) lib/lp/code/browser/codeimport.py (+1/-1) lib/lp/code/browser/codereviewvote.py (+1/-1) lib/lp/code/browser/sourcepackagerecipe.py (+5/-5) lib/lp/code/interfaces/codeimport.py (+1/-1) lib/lp/code/mail/codehandler.py (+2/-2) lib/lp/code/model/sourcepackagerecipebuild.py (+1/-1) lib/lp/code/model/tests/test_codeimportjob.py (+1/-1) lib/lp/code/xmlrpc/branch.py (+12/-12) lib/lp/code/xmlrpc/codehosting.py (+5/-5) lib/lp/codehosting/codeimport/tests/helpers.py (+1/-1) lib/lp/codehosting/codeimport/tests/servers.py (+1/-1) lib/lp/codehosting/codeimport/worker.py (+3/-3) lib/lp/codehosting/inmemory.py (+2/-2) lib/lp/codehosting/puller/__init__.py (+1/-1) lib/lp/codehosting/puller/worker.py (+11/-11) lib/lp/codehosting/safe_open.py (+1/-1) lib/lp/codehosting/scripts/modifiedbranches.py (+1/-1) lib/lp/codehosting/sftp.py (+1/-1) lib/lp/codehosting/sshserver/session.py (+2/-2) lib/lp/codehosting/vfs/transport.py (+1/-1) lib/lp/hardwaredb/scripts/hwdbsubmissions.py (+3/-3) lib/lp/poppy/hooks.py (+1/-1) lib/lp/poppy/twistedsftp.py (+1/-1) lib/lp/registry/browser/nameblacklist.py (+1/-1) lib/lp/registry/browser/person.py (+2/-2) lib/lp/registry/browser/productseries.py (+2/-2) lib/lp/registry/browser/team.py (+3/-3) lib/lp/registry/browser/teammembership.py (+2/-2) lib/lp/registry/interfaces/distroseries.py (+1/-1) lib/lp/registry/model/codeofconduct.py (+1/-1) lib/lp/registry/model/distroseries.py (+1/-1) lib/lp/registry/scripts/distributionmirror_prober.py (+4/-4) lib/lp/registry/scripts/mlistimport.py (+1/-1) lib/lp/registry/scripts/productreleasefinder/walker.py (+4/-4) lib/lp/registry/tests/test_distributionmirror_prober.py (+3/-3) lib/lp/registry/tests/test_mlists.py (+1/-1) lib/lp/registry/tests/test_packaging.py (+1/-1) lib/lp/registry/tests/test_person.py (+1/-1) lib/lp/registry/tests/test_project_milestone.py (+1/-1) lib/lp/registry/tests/test_xmlrpc.py (+2/-2) lib/lp/scripts/garbo.py (+1/-1) lib/lp/scripts/runlaunchpad.py (+1/-1) lib/lp/scripts/utilities/killservice.py (+4/-4) lib/lp/scripts/utilities/pageperformancereport.py (+2/-2) lib/lp/services/apachelogparser/base.py (+1/-1) lib/lp/services/command_spawner.py (+1/-1) lib/lp/services/config/__init__.py (+1/-1) lib/lp/services/config/tests/test_config.py (+1/-1) lib/lp/services/doc/pidfile.txt (+1/-1) lib/lp/services/features/browser/edit.py (+2/-1) lib/lp/services/fields/__init__.py (+1/-1) lib/lp/services/googlesearch/__init__.py (+1/-1) lib/lp/services/googlesearch/googletestservice.py (+4/-4) lib/lp/services/googlesearch/tests/googleserviceharness.py (+1/-1) lib/lp/services/googlesearch/tests/test_googleservice.py (+1/-1) lib/lp/services/gpg/doc/gpg-signatures.txt (+1/-1) lib/lp/services/gpg/handler.py (+5/-5) lib/lp/services/job/celeryconfig.py (+1/-1) lib/lp/services/librarian/client.py (+2/-2) lib/lp/services/librarian/tests/test_client.py (+1/-1) lib/lp/services/librarianserver/librariangc.py (+1/-1) lib/lp/services/librarianserver/libraryprotocol.py (+1/-1) lib/lp/services/librarianserver/storage.py (+2/-2) lib/lp/services/librarianserver/tests/test_db_outage.py (+1/-1) lib/lp/services/librarianserver/tests/test_web.py (+2/-2) lib/lp/services/mail/basemailer.py (+2/-2) lib/lp/services/mail/incoming.py (+7/-7) lib/lp/services/mail/mailbox.py (+4/-4) lib/lp/services/mailman/doc/logging.txt (+1/-1) lib/lp/services/mailman/monkeypatches/lphandler.py (+1/-1) lib/lp/services/mailman/monkeypatches/lpstanding.py (+1/-1) lib/lp/services/mailman/monkeypatches/xmlrpcrunner.py (+9/-9) lib/lp/services/mailman/runmailman.py (+3/-3) lib/lp/services/mailman/testing/helpers.py (+2/-2) lib/lp/services/mailman/tests/test_mailman.py (+2/-2) lib/lp/services/messaging/rabbit.py (+1/-1) lib/lp/services/osutils.py (+7/-7) lib/lp/services/salesforce/proxy.py (+1/-1) lib/lp/services/scripts/base.py (+4/-4) lib/lp/services/temporaryblobstorage/browser.py (+1/-1) lib/lp/services/twistedsupport/__init__.py (+1/-1) lib/lp/services/twistedsupport/tests/test_xmlrpc.py (+1/-1) lib/lp/services/verification/browser/logintoken.py (+4/-4) lib/lp/services/webapp/adapter.py (+1/-1) lib/lp/services/webapp/batching.py (+1/-1) lib/lp/services/webapp/publisher.py (+1/-1) lib/lp/services/webapp/tests/test_error.py (+1/-1) lib/lp/services/webapp/tests/test_errorlog.py (+2/-2) lib/lp/services/webservice/doc/webservice-error.txt (+1/-1) lib/lp/soyuz/adapters/packagelocation.py (+3/-3) lib/lp/soyuz/browser/archive.py (+1/-1) lib/lp/soyuz/browser/queue.py (+2/-2) lib/lp/soyuz/doc/distroseriesqueue.txt (+6/-6) lib/lp/soyuz/doc/manage-chroot.txt (+5/-5) lib/lp/soyuz/doc/soyuz-upload.txt (+1/-1) lib/lp/soyuz/model/binarypackagebuild.py (+2/-2) lib/lp/soyuz/model/packagecopyjob.py (+1/-1) lib/lp/soyuz/model/publishing.py (+1/-1) lib/lp/soyuz/model/queue.py (+3/-3) lib/lp/soyuz/scripts/add_missing_builds.py (+2/-2) lib/lp/soyuz/scripts/buildd.py (+1/-1) lib/lp/soyuz/scripts/chrootmanager.py (+3/-3) lib/lp/soyuz/scripts/ftpmasterbase.py (+2/-2) lib/lp/soyuz/scripts/gina/packages.py (+1/-1) lib/lp/soyuz/scripts/initialize_distroseries.py (+1/-1) lib/lp/soyuz/scripts/packagecopier.py (+2/-2) lib/lp/soyuz/scripts/publishdistro.py (+1/-1) lib/lp/soyuz/scripts/querydistro.py (+1/-1) lib/lp/soyuz/scripts/queue.py (+7/-7) lib/lp/soyuz/tests/test_distroseriesdifferencejob.py (+1/-1) lib/lp/testing/browser.py (+1/-1) lib/lp/testing/keyserver/web.py (+1/-1) lib/lp/testing/layers.py (+5/-5) lib/lp/testing/matchers.py (+1/-1) lib/lp/testing/pgsql.py (+3/-3) lib/lp/testing/tests/test_matchers.py (+1/-1) lib/lp/translations/browser/language.py (+1/-1) lib/lp/translations/browser/tests/distroseries-views.txt (+1/-1) lib/lp/translations/browser/translationmessage.py (+1/-1) lib/lp/translations/model/pofile.py (+2/-2) lib/lp/translations/model/potemplate.py (+2/-2) lib/lp/translations/model/translationtemplatesbuildjob.py (+1/-1) lib/lp/translations/scripts/copy_distroseries_translations.py (+1/-1) lib/lp/translations/scripts/gettext_check_messages.py (+1/-1) lib/lp/translations/scripts/language_pack.py (+1/-1) lib/lp/translations/scripts/po_import.py (+2/-2) lib/lp/translations/scripts/validate_translations_file.py (+1/-1) lib/lp/translations/scripts/verify_pofile_stats.py (+1/-1) lib/lp/translations/stories/translationgroups/xx-link-to-documentation.txt (+1/-1) lib/lp/translations/tests/test_pottery_detect_intltool.py (+1/-1) lib/lp/translations/utilities/gettext_po_parser.py (+3/-3) lib/lp/translations/utilities/mozilla_xpi_importer.py (+1/-1) lib/lp/translations/utilities/mozilla_zip.py (+1/-1) lib/lp/translations/utilities/pluralforms.py (+1/-1) lib/lp/translations/utilities/tests/test_gettext_po_parser.py (+1/-1) lib/lp/translations/utilities/tests/test_translation_message_data.py (+1/-1) lib/lp/translations/utilities/translation_import.py (+1/-1) lib/lp/translations/utilities/validate.py (+1/-1) lib/lp/translations/utilities/xpi_header.py (+1/-1) lib/lp/xmlrpc/helpers.py (+1/-1) lib/lp_sitecustomize.py (+1/-1) scripts/ftpmaster-tools/buildd-mass-retry.py (+3/-3) scripts/ftpmaster-tools/queue (+1/-1) scripts/script-monitor-nagios.py (+1/-1) scripts/stop-loggerhead.py (+2/-2) test_on_merge.py (+3/-3) utilities/check-configs.py (+2/-2) utilities/check-content-interfaces.py (+2/-2) utilities/community-contributions.py (+1/-1) utilities/findimports.py (+1/-1) utilities/formatdoctest.py (+1/-1) utilities/link-external-sourcecode (+1/-1) utilities/pgmassacre.py (+1/-1) utilities/tcpwatch/tcpwatch.py (+1/-1) |
| To merge this branch: | bzr merge lp:~cjwatson/launchpad/new-style-except |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Benji York (community) | code | 2012-06-29 | Approve on 2012-07-02 |
|
Review via email:
|
|||
Commit Message
Use new-style "except Exception as e" syntax rather than "except Exception, e".
Description of the Change
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://
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.
To post a comment you must log in.
| Colin Watson (cjwatson) wrote : | # |
Thanks, I've fixed these problems. Please re-review?
| Benji York (benji) wrote : | # |
> Thanks, I've fixed these problems. Please re-review?
Looks good.
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'buildmailman.py' |
| 2 | --- buildmailman.py 2012-01-01 03:20:03 +0000 |
| 3 | +++ buildmailman.py 2012-07-03 08:07:22 +0000 |
| 4 | @@ -79,7 +79,7 @@ |
| 5 | # I think Linux does not ignore it -- better safe than sorry). |
| 6 | try: |
| 7 | os.makedirs(var_dir) |
| 8 | - except OSError, e: |
| 9 | + except OSError as e: |
| 10 | if e.errno != errno.EEXIST: |
| 11 | raise |
| 12 | os.chown(var_dir, uid, gid) |
| 13 | @@ -190,7 +190,7 @@ |
| 14 | # deactivated lists. |
| 15 | try: |
| 16 | os.mkdir(os.path.join(Mailman.mm_cfg.VAR_PREFIX, 'backups')) |
| 17 | - except OSError, e: |
| 18 | + except OSError as e: |
| 19 | if e.errno != errno.EEXIST: |
| 20 | raise |
| 21 | |
| 22 | |
| 23 | === modified file 'bzrplugins/lpserve/__init__.py' |
| 24 | --- bzrplugins/lpserve/__init__.py 2011-12-21 06:14:46 +0000 |
| 25 | +++ bzrplugins/lpserve/__init__.py 2012-07-03 08:07:22 +0000 |
| 26 | @@ -632,7 +632,7 @@ |
| 27 | conn, client_addr = self._server_socket.accept() |
| 28 | except self._socket_timeout: |
| 29 | pass # Run shutdown and children checks. |
| 30 | - except self._socket_error, e: |
| 31 | + except self._socket_error as e: |
| 32 | if e.args[0] == errno.EINTR: |
| 33 | pass # Run shutdown and children checks. |
| 34 | elif e.args[0] != errno.EBADF: |
| 35 | @@ -709,7 +709,7 @@ |
| 36 | while self._child_processes: |
| 37 | try: |
| 38 | c_id, exit_code, rusage = os.wait3(os.WNOHANG) |
| 39 | - except OSError, e: |
| 40 | + except OSError as e: |
| 41 | if e.errno == errno.ECHILD: |
| 42 | # TODO: We handle this right now because the test suite |
| 43 | # fakes a child, since we wanted to test some code |
| 44 | @@ -735,7 +735,7 @@ |
| 45 | # See [Decision #4] |
| 46 | try: |
| 47 | sock.sendall('exited\n%s\n' % (exit_code,)) |
| 48 | - except (self._socket_timeout, self._socket_error), e: |
| 49 | + except (self._socket_timeout, self._socket_error) as e: |
| 50 | # The client disconnected before we wanted them to, |
| 51 | # no big deal |
| 52 | trace.mutter('%s\'s socket already closed: %s' % (c_id, e)) |
| 53 | @@ -791,7 +791,7 @@ |
| 54 | try: |
| 55 | command_argv = self.command_to_argv(command) |
| 56 | env = self.parse_env(env) |
| 57 | - except Exception, e: |
| 58 | + except Exception as e: |
| 59 | # TODO: Log the traceback? |
| 60 | self.log(client_addr, 'command or env parsing failed: %r' |
| 61 | % (str(e),)) |
| 62 | @@ -820,7 +820,7 @@ |
| 63 | elif request.startswith('child_connect_timeout '): |
| 64 | try: |
| 65 | value = int(request.split(' ', 1)[1]) |
| 66 | - except ValueError, e: |
| 67 | + except ValueError as e: |
| 68 | conn.sendall('FAILURE: %r\n' % (e,)) |
| 69 | else: |
| 70 | self._child_connect_timeout = value |
| 71 | @@ -877,7 +877,7 @@ |
| 72 | for pyname in libraries_to_preload: |
| 73 | try: |
| 74 | __import__(pyname) |
| 75 | - except ImportError, e: |
| 76 | + except ImportError as e: |
| 77 | trace.mutter('failed to preload %s: %s' % (pyname, e)) |
| 78 | |
| 79 | def _daemonize(self, pid_filename): |
| 80 | @@ -935,7 +935,7 @@ |
| 81 | if pid_file is not None: |
| 82 | try: |
| 83 | os.remove(pid_file) |
| 84 | - except (OSError, IOError), e: |
| 85 | + except (OSError, IOError) as e: |
| 86 | trace.mutter('Failed to cleanup pid_file: %s\n%s' |
| 87 | % (pid_file, e)) |
| 88 | |
| 89 | |
| 90 | === modified file 'bzrplugins/lpserve/test_lpserve.py' |
| 91 | --- bzrplugins/lpserve/test_lpserve.py 2012-04-03 15:56:48 +0000 |
| 92 | +++ bzrplugins/lpserve/test_lpserve.py 2012-07-03 08:07:22 +0000 |
| 93 | @@ -641,12 +641,12 @@ |
| 94 | def _cleanup_daemon(self, pid, pid_filename): |
| 95 | try: |
| 96 | os.kill(pid, signal.SIGKILL) |
| 97 | - except (OSError, IOError), e: |
| 98 | + except (OSError, IOError) as e: |
| 99 | trace.mutter('failed to kill pid %d, might be already dead: %s' |
| 100 | % (pid, e)) |
| 101 | try: |
| 102 | os.remove(pid_filename) |
| 103 | - except (OSError, IOError), e: |
| 104 | + except (OSError, IOError) as e: |
| 105 | if e.errno != errno.ENOENT: |
| 106 | trace.mutter('failed to remove %r: %s' |
| 107 | % (pid_filename, e)) |
| 108 | @@ -697,7 +697,7 @@ |
| 109 | # message |
| 110 | try: |
| 111 | response = self.send_message_to_service('quit\n') |
| 112 | - except socket.error, e: |
| 113 | + except socket.error as e: |
| 114 | # Ignore a failure to connect; the service must be |
| 115 | # stopping/stopped already. |
| 116 | response = None |
| 117 | @@ -714,7 +714,7 @@ |
| 118 | while tnow < tend: |
| 119 | try: |
| 120 | os.kill(self.service_process, 0) |
| 121 | - except (OSError, IOError), e: |
| 122 | + except (OSError, IOError) as e: |
| 123 | if e.errno == errno.ESRCH: |
| 124 | # The process has successfully exited |
| 125 | stopped = True |
| 126 | @@ -729,7 +729,7 @@ |
| 127 | unclean = True |
| 128 | try: |
| 129 | os.kill(self.service_process, sig) |
| 130 | - except (OSError, IOError), e: |
| 131 | + except (OSError, IOError) as e: |
| 132 | if e.errno == errno.ESRCH: |
| 133 | stopped = True |
| 134 | break |
| 135 | |
| 136 | === modified file 'cronscripts/process-mail.py' |
| 137 | --- cronscripts/process-mail.py 2012-01-01 03:14:54 +0000 |
| 138 | +++ cronscripts/process-mail.py 2012-07-03 08:07:22 +0000 |
| 139 | @@ -27,7 +27,7 @@ |
| 140 | def main(self): |
| 141 | try: |
| 142 | handleMail(self.txn) |
| 143 | - except ComponentLookupError, lookup_error: |
| 144 | + except ComponentLookupError as lookup_error: |
| 145 | if lookup_error.args[0] != IMailBox: |
| 146 | raise |
| 147 | raise LaunchpadScriptFailure( |
| 148 | |
| 149 | === modified file 'cronscripts/publishing/maintenance-check.py' |
| 150 | --- cronscripts/publishing/maintenance-check.py 2012-02-23 10:43:19 +0000 |
| 151 | +++ cronscripts/publishing/maintenance-check.py 2012-07-03 08:07:22 +0000 |
| 152 | @@ -431,7 +431,7 @@ |
| 153 | pkg_support_time[pkgname] = support_time |
| 154 | except: |
| 155 | logging.exception("can not parse line '%s'" % line) |
| 156 | - except urllib2.HTTPError, e: |
| 157 | + except urllib2.HTTPError as e: |
| 158 | if e.code != 404: |
| 159 | raise |
| 160 | sys.stderr.write("hints-file: %s gave 404 error\n" % hints_file) |
| 161 | |
| 162 | === modified file 'cronscripts/reprocess-hwdb-submissions.py' |
| 163 | --- cronscripts/reprocess-hwdb-submissions.py 2012-01-01 03:14:54 +0000 |
| 164 | +++ cronscripts/reprocess-hwdb-submissions.py 2012-07-03 08:07:22 +0000 |
| 165 | @@ -69,7 +69,7 @@ |
| 166 | try: |
| 167 | start_file = open(self.options.start_file, 'r+') |
| 168 | start_id = start_file.read().strip() |
| 169 | - except IOError, error: |
| 170 | + except IOError as error: |
| 171 | self.logger.error( |
| 172 | 'Cannot access file %s: %s' % ( |
| 173 | self.options.start_file, error)) |
| 174 | |
| 175 | === modified file 'daemons/cache-database-replication-lag.py' |
| 176 | --- daemons/cache-database-replication-lag.py 2011-12-30 06:47:17 +0000 |
| 177 | +++ daemons/cache-database-replication-lag.py 2012-07-03 08:07:22 +0000 |
| 178 | @@ -50,7 +50,7 @@ |
| 179 | else: |
| 180 | log.error("update_replication_lag_cache() failed.") |
| 181 | time.sleep(options.sleep) |
| 182 | - except psycopg2.Error, x: |
| 183 | + except psycopg2.Error as x: |
| 184 | log.error("%s. Retrying.", str(x).strip()) |
| 185 | time.sleep(options.sleep) |
| 186 | |
| 187 | |
| 188 | === modified file 'database/replication/new-slave.py' |
| 189 | --- database/replication/new-slave.py 2012-04-24 14:53:06 +0000 |
| 190 | +++ database/replication/new-slave.py 2012-07-03 08:07:22 +0000 |
| 191 | @@ -56,7 +56,7 @@ |
| 192 | "Opening source connection to '%s'" % source_connection_string) |
| 193 | source_connection = psycopg2.connect(str(source_connection_string)) |
| 194 | source_connection.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) |
| 195 | - except psycopg2.Error, exception: |
| 196 | + except psycopg2.Error as exception: |
| 197 | parser.error("Unable to connect as %s (%s)" % ( |
| 198 | source_connection_string, str(exception).strip())) |
| 199 | |
| 200 | @@ -92,7 +92,7 @@ |
| 201 | # Keep the connection as we need it. |
| 202 | try: |
| 203 | target_con = psycopg2.connect(str(target_connection_string)) |
| 204 | - except psycopg2.Error, exception: |
| 205 | + except psycopg2.Error as exception: |
| 206 | parser.error("Failed to connect using '%s' (%s)" % ( |
| 207 | target_connection_string, str(exception).strip())) |
| 208 | |
| 209 | @@ -250,7 +250,7 @@ |
| 210 | try: |
| 211 | # Test connection only. We're not going to use it. |
| 212 | psycopg2.connect(str(connection_string)) |
| 213 | - except psycopg2.Error, exception: |
| 214 | + except psycopg2.Error as exception: |
| 215 | parser.error("Failed to connect to using '%s' (%s)" % ( |
| 216 | connection_string, str(exception).strip())) |
| 217 | |
| 218 | |
| 219 | === modified file 'database/schema/full-update.py' |
| 220 | --- database/schema/full-update.py 2012-07-01 08:22:23 +0000 |
| 221 | +++ database/schema/full-update.py 2012-07-03 08:07:22 +0000 |
| 222 | @@ -61,7 +61,7 @@ |
| 223 | except Exception: |
| 224 | log.exception('Unhandled exception') |
| 225 | return 1 |
| 226 | - except SystemExit, x: |
| 227 | + except SystemExit as x: |
| 228 | log.fatal("upgrade.py failed [%s]", x) |
| 229 | |
| 230 | |
| 231 | @@ -84,7 +84,7 @@ |
| 232 | except Exception: |
| 233 | log.exception('Unhandled exception') |
| 234 | return 1 |
| 235 | - except SystemExit, x: |
| 236 | + except SystemExit as x: |
| 237 | log.fatal("security.py failed [%s]", x) |
| 238 | |
| 239 | |
| 240 | |
| 241 | === modified file 'ez_setup.py' |
| 242 | --- ez_setup.py 2010-04-07 18:39:30 +0000 |
| 243 | +++ ez_setup.py 2012-07-03 08:07:22 +0000 |
| 244 | @@ -107,7 +107,7 @@ |
| 245 | return do_download() |
| 246 | try: |
| 247 | pkg_resources.require("setuptools>="+version); return |
| 248 | - except pkg_resources.VersionConflict, e: |
| 249 | + except pkg_resources.VersionConflict as e: |
| 250 | if was_imported: |
| 251 | print >>sys.stderr, ( |
| 252 | "The required version of setuptools (>=%s) is not available, and\n" |
| 253 | |
| 254 | === modified file 'lib/BeautifulSoup.py' |
| 255 | --- lib/BeautifulSoup.py 2009-08-04 17:44:01 +0000 |
| 256 | +++ lib/BeautifulSoup.py 2012-07-03 08:07:22 +0000 |
| 257 | @@ -1586,7 +1586,7 @@ |
| 258 | u = self._toUnicode(markup, proposed) |
| 259 | self.markup = u |
| 260 | self.originalEncoding = proposed |
| 261 | - except Exception, e: |
| 262 | + except Exception as e: |
| 263 | # print "That didn't work!" |
| 264 | # print e |
| 265 | return None |
| 266 | |
| 267 | === modified file 'lib/contrib/apachelog.py' |
| 268 | --- lib/contrib/apachelog.py 2011-01-18 23:18:43 +0000 |
| 269 | +++ lib/contrib/apachelog.py 2012-07-03 08:07:22 +0000 |
| 270 | @@ -167,7 +167,7 @@ |
| 271 | self._pattern = '^' + ' '.join(subpatterns) + '$' |
| 272 | try: |
| 273 | self._regex = re.compile(self._pattern) |
| 274 | - except Exception, e: |
| 275 | + except Exception as e: |
| 276 | raise ApacheLogParserError(e) |
| 277 | |
| 278 | def parse(self, line): |
| 279 | |
| 280 | === modified file 'lib/contrib/glock.py' |
| 281 | --- lib/contrib/glock.py 2010-03-30 03:11:26 +0000 |
| 282 | +++ lib/contrib/glock.py 2012-07-03 08:07:22 +0000 |
| 283 | @@ -177,7 +177,7 @@ |
| 284 | options = fcntl.LOCK_EX|fcntl.LOCK_NB |
| 285 | try: |
| 286 | fcntl.flock(self.fdlock, options) |
| 287 | - except IOError, message: #(errno 13: perm. denied, |
| 288 | + except IOError as message: #(errno 13: perm. denied, |
| 289 | # 36: Resource deadlock avoided) |
| 290 | if not blocking and self._errnoOf (message) == errno.EWOULDBLOCK: |
| 291 | raise LockAlreadyAcquired('Lock %s already acquired by ' |
| 292 | @@ -230,7 +230,7 @@ |
| 293 | try: |
| 294 | win32event.ReleaseMutex(self.mutex) |
| 295 | #print "released mutex" |
| 296 | - except pywintypes.error, e: |
| 297 | + except pywintypes.error as e: |
| 298 | errCode, fctName, errMsg = e.args |
| 299 | if errCode == 288: |
| 300 | raise NotOwner("Attempt to release somebody else's lock") |
| 301 | |
| 302 | === modified file 'lib/launchpad_loggerhead/app.py' |
| 303 | --- lib/launchpad_loggerhead/app.py 2012-02-03 05:35:54 +0000 |
| 304 | +++ lib/launchpad_loggerhead/app.py 2012-07-03 08:07:22 +0000 |
| 305 | @@ -192,7 +192,7 @@ |
| 306 | try: |
| 307 | transport_type, info, trail = self.branchfs.translatePath( |
| 308 | user, urlutils.escape(path)) |
| 309 | - except xmlrpclib.Fault, f: |
| 310 | + except xmlrpclib.Fault as f: |
| 311 | if check_fault(f, faults.PathTranslationError): |
| 312 | raise HTTPNotFound() |
| 313 | elif check_fault(f, faults.PermissionDenied): |
| 314 | @@ -275,7 +275,7 @@ |
| 315 | try: |
| 316 | bzr_branch = safe_open( |
| 317 | lp_server.get_url().strip(':/'), branch_url) |
| 318 | - except errors.NotBranchError, err: |
| 319 | + except errors.NotBranchError as err: |
| 320 | self.log.warning('Not a branch: %s', err) |
| 321 | raise HTTPNotFound() |
| 322 | bzr_branch.lock_read() |
| 323 | |
| 324 | === modified file 'lib/lp/app/browser/folder.py' |
| 325 | --- lib/lp/app/browser/folder.py 2012-01-01 02:58:52 +0000 |
| 326 | +++ lib/lp/app/browser/folder.py 2012-07-03 08:07:22 +0000 |
| 327 | @@ -88,7 +88,7 @@ |
| 328 | name = os.path.basename(filename) |
| 329 | try: |
| 330 | fileobj = File(filename, name) |
| 331 | - except IOError, ioerror: |
| 332 | + except IOError as ioerror: |
| 333 | expected = (errno.ENOENT, errno.EISDIR, errno.ENOTDIR) |
| 334 | if ioerror.errno in expected: |
| 335 | # No such file or is a directory. |
| 336 | |
| 337 | === modified file 'lib/lp/app/browser/launchpad.py' |
| 338 | --- lib/lp/app/browser/launchpad.py 2012-06-15 04:07:30 +0000 |
| 339 | +++ lib/lp/app/browser/launchpad.py 2012-07-03 08:07:22 +0000 |
| 340 | @@ -623,7 +623,7 @@ |
| 341 | target_url = canonical_url(branch) |
| 342 | if trailing is not None: |
| 343 | target_url = urlappend(target_url, trailing) |
| 344 | - except (NoLinkedBranch), e: |
| 345 | + except (NoLinkedBranch) as e: |
| 346 | # A valid ICanHasLinkedBranch target exists but there's no |
| 347 | # branch or it's not visible. |
| 348 | |
| 349 | @@ -636,7 +636,7 @@ |
| 350 | self.request.response.addNotification( |
| 351 | "The target %s does not have a linked branch." % path) |
| 352 | except (CannotHaveLinkedBranch, InvalidNamespace, |
| 353 | - InvalidProductName, NotFoundError), e: |
| 354 | + InvalidProductName, NotFoundError) as e: |
| 355 | # If are aren't arriving at this invalid branch URL from another |
| 356 | # page then we just raise a NotFoundError to generate a 404, |
| 357 | # otherwise we end up in a bad recursion loop. The target url will |
| 358 | |
| 359 | === modified file 'lib/lp/app/browser/tales.py' |
| 360 | --- lib/lp/app/browser/tales.py 2012-06-15 16:23:50 +0000 |
| 361 | +++ lib/lp/app/browser/tales.py 2012-07-03 08:07:22 +0000 |
| 362 | @@ -322,7 +322,7 @@ |
| 363 | except NoCanonicalUrl: |
| 364 | menu = None |
| 365 | return self._getMenuLinksAndAttributes(menu) |
| 366 | - except AttributeError, e: |
| 367 | + except AttributeError as e: |
| 368 | # If this method gets an AttributeError, we rethrow it as a |
| 369 | # AssertionError. Otherwise, zope will hide the root cause |
| 370 | # of the error and just say that "navigation" can't be traversed. |
| 371 | |
| 372 | === modified file 'lib/lp/app/widgets/date.py' |
| 373 | --- lib/lp/app/widgets/date.py 2012-01-01 02:58:52 +0000 |
| 374 | +++ lib/lp/app/widgets/date.py 2012-07-03 08:07:22 +0000 |
| 375 | @@ -340,7 +340,7 @@ |
| 376 | for fmt in self.supported_input_formats: |
| 377 | try: |
| 378 | datetime.strptime(input.strip(), fmt) |
| 379 | - except (ValueError), e: |
| 380 | + except (ValueError) as e: |
| 381 | if 'unconverted data remains' in str(e): |
| 382 | return |
| 383 | else: |
| 384 | @@ -397,7 +397,7 @@ |
| 385 | micro = round(micro * 1000000) |
| 386 | dt = datetime(year, month, day, |
| 387 | hour, minute, int(second), int(micro)) |
| 388 | - except (DateTimeError, ValueError, IndexError), v: |
| 389 | + except (DateTimeError, ValueError, IndexError) as v: |
| 390 | raise ConversionError('Invalid date value', v) |
| 391 | return self.time_zone.localize(dt) |
| 392 | |
| 393 | |
| 394 | === modified file 'lib/lp/app/widgets/image.py' |
| 395 | --- lib/lp/app/widgets/image.py 2012-01-01 02:58:52 +0000 |
| 396 | +++ lib/lp/app/widgets/image.py 2012-07-03 08:07:22 +0000 |
| 397 | @@ -138,7 +138,7 @@ |
| 398 | self._image = form.getOne(self.image_widget.name) |
| 399 | try: |
| 400 | self.context.validate(self._image) |
| 401 | - except ValidationError, v: |
| 402 | + except ValidationError as v: |
| 403 | self._error = WidgetInputError(self.name, self.label, v) |
| 404 | raise self._error |
| 405 | self._image.seek(0) |
| 406 | |
| 407 | === modified file 'lib/lp/app/widgets/launchpadtarget.py' |
| 408 | --- lib/lp/app/widgets/launchpadtarget.py 2012-02-22 00:04:43 +0000 |
| 409 | +++ lib/lp/app/widgets/launchpadtarget.py 2012-07-03 08:07:22 +0000 |
| 410 | @@ -187,7 +187,7 @@ |
| 411 | try: |
| 412 | if self.hasInput(): |
| 413 | self.getInputValue() |
| 414 | - except InputErrors, error: |
| 415 | + except InputErrors as error: |
| 416 | self._error = error |
| 417 | return super(LaunchpadTargetWidget, self).error() |
| 418 | |
| 419 | |
| 420 | === modified file 'lib/lp/app/widgets/tests/test_datetime.py' |
| 421 | --- lib/lp/app/widgets/tests/test_datetime.py 2012-06-14 05:18:22 +0000 |
| 422 | +++ lib/lp/app/widgets/tests/test_datetime.py 2012-07-03 08:07:22 +0000 |
| 423 | @@ -38,7 +38,7 @@ |
| 424 | fmt = "%Y-%m-%d" |
| 425 | try: |
| 426 | datetime.strptime(test_str, fmt) |
| 427 | - except (ValueError,), e: |
| 428 | + except ValueError as e: |
| 429 | self.assertTrue('unconverted data' in str(e)) |
| 430 | |
| 431 | def test_whitespace_does_not_trick_validation(self): |
| 432 | |
| 433 | === modified file 'lib/lp/app/widgets/textwidgets.py' |
| 434 | --- lib/lp/app/widgets/textwidgets.py 2011-11-17 17:18:32 +0000 |
| 435 | +++ lib/lp/app/widgets/textwidgets.py 2012-07-03 08:07:22 +0000 |
| 436 | @@ -106,7 +106,7 @@ |
| 437 | micro = round(micro * 1000000) |
| 438 | dt = datetime.datetime(year, month, day, |
| 439 | hour, minute, int(second), int(micro)) |
| 440 | - except (DateTimeError, ValueError, IndexError), v: |
| 441 | + except (DateTimeError, ValueError, IndexError) as v: |
| 442 | raise ConversionError('Invalid date value', v) |
| 443 | tz = pytz.timezone(self.timeZoneName) |
| 444 | return tz.localize(dt) |
| 445 | |
| 446 | === modified file 'lib/lp/archivepublisher/customupload.py' |
| 447 | --- lib/lp/archivepublisher/customupload.py 2012-05-30 10:25:43 +0000 |
| 448 | +++ lib/lp/archivepublisher/customupload.py 2012-07-03 08:07:22 +0000 |
| 449 | @@ -206,7 +206,7 @@ |
| 450 | tar.extract(tarinfo, self.tmpdir) |
| 451 | finally: |
| 452 | tar.close() |
| 453 | - except tarfile.TarError, exc: |
| 454 | + except tarfile.TarError as exc: |
| 455 | raise CustomUploadTarballTarError(self.tarfile_path, exc) |
| 456 | |
| 457 | def shouldInstall(self, filename): |
| 458 | |
| 459 | === modified file 'lib/lp/archivepublisher/deathrow.py' |
| 460 | --- lib/lp/archivepublisher/deathrow.py 2011-12-30 06:14:56 +0000 |
| 461 | +++ lib/lp/archivepublisher/deathrow.py 2012-07-03 08:07:22 +0000 |
| 462 | @@ -277,11 +277,11 @@ |
| 463 | try: |
| 464 | bytes += self._removeFile( |
| 465 | component_name, source_name, file_name) |
| 466 | - except NotInPool, info: |
| 467 | + except NotInPool as info: |
| 468 | # It's safe for us to let this slide because it means that |
| 469 | # the file is already gone. |
| 470 | self.logger.debug(str(info)) |
| 471 | - except MissingSymlinkInPool, info: |
| 472 | + except MissingSymlinkInPool as info: |
| 473 | # This one is a little more worrying, because an expected |
| 474 | # symlink has vanished from the pool/ (could be a code |
| 475 | # mistake) but there is nothing we can do about it at this |
| 476 | |
| 477 | === modified file 'lib/lp/archivepublisher/debversion.py' |
| 478 | --- lib/lp/archivepublisher/debversion.py 2010-08-20 20:31:18 +0000 |
| 479 | +++ lib/lp/archivepublisher/debversion.py 2012-07-03 08:07:22 +0000 |
| 480 | @@ -65,7 +65,7 @@ |
| 481 | |
| 482 | try: |
| 483 | changelog.Version.__init__(self, ver) |
| 484 | - except ValueError, e: |
| 485 | + except ValueError as e: |
| 486 | raise VersionError(e) |
| 487 | |
| 488 | if self.epoch is not None: |
| 489 | |
| 490 | === modified file 'lib/lp/archivepublisher/dist_upgrader.py' |
| 491 | --- lib/lp/archivepublisher/dist_upgrader.py 2012-05-30 10:25:43 +0000 |
| 492 | +++ lib/lp/archivepublisher/dist_upgrader.py 2012-07-03 08:07:22 +0000 |
| 493 | @@ -90,7 +90,7 @@ |
| 494 | directory_name = filename.split(os.path.sep)[0] |
| 495 | try: |
| 496 | version = make_version(directory_name) |
| 497 | - except BadUpstreamError, exc: |
| 498 | + except BadUpstreamError as exc: |
| 499 | raise DistUpgraderBadVersion(self.tarfile_path, exc) |
| 500 | return version and not filename.startswith('current') |
| 501 | |
| 502 | |
| 503 | === modified file 'lib/lp/archivepublisher/publishing.py' |
| 504 | --- lib/lp/archivepublisher/publishing.py 2012-06-19 02:33:21 +0000 |
| 505 | +++ lib/lp/archivepublisher/publishing.py 2012-07-03 08:07:22 +0000 |
| 506 | @@ -747,7 +747,7 @@ |
| 507 | continue |
| 508 | try: |
| 509 | shutil.rmtree(directory) |
| 510 | - except (shutil.Error, OSError), e: |
| 511 | + except (shutil.Error, OSError) as e: |
| 512 | self.log.warning( |
| 513 | "Failed to delete directory '%s' for archive " |
| 514 | "'%s/%s'\n%s" % ( |
| 515 | |
| 516 | === modified file 'lib/lp/archivepublisher/scripts/generate_extra_overrides.py' |
| 517 | --- lib/lp/archivepublisher/scripts/generate_extra_overrides.py 2012-05-21 13:01:20 +0000 |
| 518 | +++ lib/lp/archivepublisher/scripts/generate_extra_overrides.py 2012-07-03 08:07:22 +0000 |
| 519 | @@ -167,7 +167,7 @@ |
| 520 | self.logger.warning( |
| 521 | "Skipping empty seed structure for %s.%s", |
| 522 | flavour, series_name) |
| 523 | - except SeedError, e: |
| 524 | + except SeedError as e: |
| 525 | self.logger.warning( |
| 526 | "Failed to fetch seeds for %s.%s: %s", |
| 527 | flavour, series_name, e) |
| 528 | |
| 529 | === modified file 'lib/lp/archiveuploader/changesfile.py' |
| 530 | --- lib/lp/archiveuploader/changesfile.py 2011-05-20 08:04:19 +0000 |
| 531 | +++ lib/lp/archiveuploader/changesfile.py 2012-07-03 08:07:22 +0000 |
| 532 | @@ -145,12 +145,12 @@ |
| 533 | # doing ensurePerson() for buildds and sync owners. |
| 534 | try: |
| 535 | self.maintainer = self.parseAddress(self._dict['Maintainer']) |
| 536 | - except UploadError, error: |
| 537 | + except UploadError as error: |
| 538 | yield error |
| 539 | |
| 540 | try: |
| 541 | self.changed_by = self.parseAddress(self._dict['Changed-By']) |
| 542 | - except UploadError, error: |
| 543 | + except UploadError as error: |
| 544 | yield error |
| 545 | |
| 546 | def isCustom(self, component_and_section): |
| 547 | @@ -204,7 +204,7 @@ |
| 548 | |
| 549 | if cls == DSCFile: |
| 550 | self.dsc = file_instance |
| 551 | - except UploadError, error: |
| 552 | + except UploadError as error: |
| 553 | yield error |
| 554 | else: |
| 555 | files.append(file_instance) |
| 556 | |
| 557 | === modified file 'lib/lp/archiveuploader/dscfile.py' |
| 558 | --- lib/lp/archiveuploader/dscfile.py 2012-01-06 11:08:30 +0000 |
| 559 | +++ lib/lp/archiveuploader/dscfile.py 2012-07-03 08:07:22 +0000 |
| 560 | @@ -96,7 +96,7 @@ |
| 561 | """ |
| 562 | try: |
| 563 | shutil.rmtree(unpacked_dir) |
| 564 | - except OSError, error: |
| 565 | + except OSError as error: |
| 566 | if errno.errorcode[error.errno] != 'EACCES': |
| 567 | raise UploadError( |
| 568 | "couldn't remove tmp dir %s: code %s" % ( |
| 569 | @@ -132,7 +132,7 @@ |
| 570 | try: |
| 571 | with open(self.filepath, 'rb') as f: |
| 572 | self.raw_content = f.read() |
| 573 | - except IOError, error: |
| 574 | + except IOError as error: |
| 575 | raise UploadError( |
| 576 | "Unable to read %s: %s" % (self.filename, error)) |
| 577 | |
| 578 | @@ -145,7 +145,7 @@ |
| 579 | try: |
| 580 | self._dict = parse_tagfile_content( |
| 581 | self.parsed_content, filename=self.filepath) |
| 582 | - except TagFileParseError, error: |
| 583 | + except TagFileParseError as error: |
| 584 | raise UploadError( |
| 585 | "Unable to parse %s: %s" % (self.filename, error)) |
| 586 | |
| 587 | @@ -164,7 +164,7 @@ |
| 588 | try: |
| 589 | sig = getUtility(IGPGHandler).getVerifiedSignatureResilient( |
| 590 | content) |
| 591 | - except GPGVerificationError, error: |
| 592 | + except GPGVerificationError as error: |
| 593 | raise UploadError( |
| 594 | "GPG verification of %s failed: %s" % ( |
| 595 | filename, str(error))) |
| 596 | @@ -195,7 +195,7 @@ |
| 597 | try: |
| 598 | (rfc822, rfc2047, name, email) = safe_fix_maintainer( |
| 599 | addr, fieldname) |
| 600 | - except ParseMaintError, error: |
| 601 | + except ParseMaintError as error: |
| 602 | raise UploadError(str(error)) |
| 603 | |
| 604 | person = getUtility(IPersonSet).getByEmail(email) |
| 605 | @@ -340,7 +340,7 @@ |
| 606 | # Check size and checksum of the DSC file itself |
| 607 | try: |
| 608 | self.checkSizeAndCheckSum() |
| 609 | - except UploadError, error: |
| 610 | + except UploadError as error: |
| 611 | yield error |
| 612 | |
| 613 | files = [] |
| 614 | @@ -358,7 +358,7 @@ |
| 615 | try: |
| 616 | file_instance = DSCUploadedFile( |
| 617 | filepath, digest, size, self.policy, self.logger) |
| 618 | - except UploadError, error: |
| 619 | + except UploadError as error: |
| 620 | yield error |
| 621 | else: |
| 622 | files.append(file_instance) |
| 623 | @@ -389,7 +389,7 @@ |
| 624 | apt_pkg.parse_src_depends(field) |
| 625 | except (SystemExit, KeyboardInterrupt): |
| 626 | raise |
| 627 | - except Exception, error: |
| 628 | + except Exception as error: |
| 629 | # Swallow everything apt_pkg throws at us because |
| 630 | # it is not desperately pythonic and can raise odd |
| 631 | # or confusing exceptions at times and is out of |
| 632 | @@ -505,7 +505,7 @@ |
| 633 | try: |
| 634 | library_file, file_archive = self._getFileByName( |
| 635 | sub_dsc_file.filename) |
| 636 | - except NotFoundError, error: |
| 637 | + except NotFoundError as error: |
| 638 | library_file = None |
| 639 | file_archive = None |
| 640 | else: |
| 641 | @@ -573,7 +573,7 @@ |
| 642 | |
| 643 | try: |
| 644 | unpacked_dir = unpack_source(self.filepath) |
| 645 | - except DpkgSourceError, e: |
| 646 | + except DpkgSourceError as e: |
| 647 | yield UploadError( |
| 648 | "dpkg-source failed for %s [return: %s]\n" |
| 649 | "[dpkg-source output: %s]" |
| 650 | @@ -600,18 +600,18 @@ |
| 651 | # processing. |
| 652 | try: |
| 653 | self.copyright = find_copyright(unpacked_dir, self.logger) |
| 654 | - except UploadError, error: |
| 655 | + except UploadError as error: |
| 656 | yield error |
| 657 | return |
| 658 | - except UploadWarning, warning: |
| 659 | + except UploadWarning as warning: |
| 660 | yield warning |
| 661 | |
| 662 | try: |
| 663 | self.changelog = find_changelog(unpacked_dir, self.logger) |
| 664 | - except UploadError, error: |
| 665 | + except UploadError as error: |
| 666 | yield error |
| 667 | return |
| 668 | - except UploadWarning, warning: |
| 669 | + except UploadWarning as warning: |
| 670 | yield warning |
| 671 | finally: |
| 672 | self.logger.debug("Cleaning up source tree.") |
| 673 | @@ -724,7 +724,7 @@ |
| 674 | """Check Sub DSCFile mentioned size & checksum.""" |
| 675 | try: |
| 676 | self.checkSizeAndCheckSum() |
| 677 | - except UploadError, error: |
| 678 | + except UploadError as error: |
| 679 | yield error |
| 680 | |
| 681 | |
| 682 | |
| 683 | === modified file 'lib/lp/archiveuploader/nascentupload.py' |
| 684 | --- lib/lp/archiveuploader/nascentupload.py 2012-06-30 17:41:37 +0000 |
| 685 | +++ lib/lp/archiveuploader/nascentupload.py 2012-07-03 08:07:22 +0000 |
| 686 | @@ -388,9 +388,9 @@ |
| 687 | """ |
| 688 | try: |
| 689 | callable() |
| 690 | - except UploadError, error: |
| 691 | + except UploadError as error: |
| 692 | self.reject("".join(error.args)) |
| 693 | - except UploadWarning, error: |
| 694 | + except UploadWarning as error: |
| 695 | self.warn("".join(error.args)) |
| 696 | |
| 697 | def run_and_collect_errors(self, callable): |
| 698 | @@ -856,14 +856,14 @@ |
| 699 | |
| 700 | except (SystemExit, KeyboardInterrupt): |
| 701 | raise |
| 702 | - except QueueInconsistentStateError, e: |
| 703 | + except QueueInconsistentStateError as e: |
| 704 | # A QueueInconsistentStateError is expected if the rejection |
| 705 | # is a routine rejection due to a bad package upload. |
| 706 | # Log at info level so LaunchpadCronScript doesn't generate an |
| 707 | # OOPS. |
| 708 | func = self.logger.info |
| 709 | return self._reject_with_logging(e, notify, func) |
| 710 | - except Exception, e: |
| 711 | + except Exception as e: |
| 712 | # Any exception which occurs while processing an accept will |
| 713 | # cause a rejection to occur. The exception is logged in the |
| 714 | # reject message rather than being swallowed up. |
| 715 | |
| 716 | === modified file 'lib/lp/archiveuploader/nascentuploadfile.py' |
| 717 | --- lib/lp/archiveuploader/nascentuploadfile.py 2012-05-25 15:31:50 +0000 |
| 718 | +++ lib/lp/archiveuploader/nascentuploadfile.py 2012-07-03 08:07:22 +0000 |
| 719 | @@ -724,7 +724,7 @@ |
| 720 | tar_checker.reset() |
| 721 | try: |
| 722 | deb_file = apt_inst.DebFile(self.filepath) |
| 723 | - except SystemError, error: |
| 724 | + except SystemError as error: |
| 725 | # We get an error from the constructor if the .deb does not |
| 726 | # contain all the expected top-level members (debian-binary, |
| 727 | # control.tar.gz, and data.tar.*). |
| 728 | @@ -753,7 +753,7 @@ |
| 729 | timestamp)) |
| 730 | except (SystemExit, KeyboardInterrupt): |
| 731 | raise |
| 732 | - except Exception, error: |
| 733 | + except Exception as error: |
| 734 | # There is a very large number of places where we |
| 735 | # might get an exception while checking the timestamps. |
| 736 | # Many of them come from apt_inst/apt_pkg and they are |
| 737 | |
| 738 | === modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py' |
| 739 | --- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2012-06-28 14:28:11 +0000 |
| 740 | +++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2012-07-03 08:07:22 +0000 |
| 741 | @@ -235,7 +235,7 @@ |
| 742 | """ |
| 743 | try: |
| 744 | callableObj(*args, **kwargs) |
| 745 | - except excClass, error: |
| 746 | + except excClass as error: |
| 747 | return error |
| 748 | else: |
| 749 | if getattr(excClass, '__name__', None) is not None: |
| 750 | |
| 751 | === modified file 'lib/lp/archiveuploader/uploadprocessor.py' |
| 752 | --- lib/lp/archiveuploader/uploadprocessor.py 2012-01-01 02:58:52 +0000 |
| 753 | +++ lib/lp/archiveuploader/uploadprocessor.py 2012-07-03 08:07:22 +0000 |
| 754 | @@ -191,7 +191,7 @@ |
| 755 | continue |
| 756 | try: |
| 757 | handler = UploadHandler.forProcessor(self, fsroot, upload) |
| 758 | - except CannotGetBuild, e: |
| 759 | + except CannotGetBuild as e: |
| 760 | self.log.warn(e) |
| 761 | else: |
| 762 | handler.process() |
| 763 | @@ -225,7 +225,7 @@ |
| 764 | # be able to do so. |
| 765 | try: |
| 766 | os.chmod(lockfile_path, mode | stat.S_IWGRP) |
| 767 | - except OSError, err: |
| 768 | + except OSError as err: |
| 769 | self.log.debug('Could not fix the lockfile permission: %s' % err) |
| 770 | |
| 771 | try: |
| 772 | @@ -326,7 +326,7 @@ |
| 773 | try: |
| 774 | (distribution, suite_name, |
| 775 | archive) = parse_upload_path(relative_path) |
| 776 | - except UploadPathError, e: |
| 777 | + except UploadPathError as e: |
| 778 | # pick some defaults to create the NascentUpload() object. |
| 779 | # We will be rejecting the upload so it doesn matter much. |
| 780 | distribution = getUtility(IDistributionSet)['ubuntu'] |
| 781 | @@ -337,7 +337,7 @@ |
| 782 | extra_info=( |
| 783 | "Please update your dput/dupload configuration " |
| 784 | "and then re-upload."))) |
| 785 | - except PPAUploadPathError, e: |
| 786 | + except PPAUploadPathError as e: |
| 787 | # Again, pick some defaults but leave a hint for the rejection |
| 788 | # emailer that it was a PPA failure. |
| 789 | distribution = getUtility(IDistributionSet)['ubuntu'] |
| 790 | @@ -408,7 +408,7 @@ |
| 791 | |
| 792 | try: |
| 793 | self._processUpload(upload) |
| 794 | - except UploadPolicyError, e: |
| 795 | + except UploadPolicyError as e: |
| 796 | upload.reject("UploadPolicyError escaped upload.process: " |
| 797 | "%s " % e) |
| 798 | logger.debug( |
| 799 | @@ -421,7 +421,7 @@ |
| 800 | upload.reject( |
| 801 | "Further error processing not possible because of " |
| 802 | "a critical previous error.") |
| 803 | - except Exception, e: |
| 804 | + except Exception as e: |
| 805 | # In case of unexpected unhandled exception, we'll |
| 806 | # *try* to reject the upload. This may fail and cause |
| 807 | # a further exception, depending on the state of the |
| 808 | |
| 809 | === modified file 'lib/lp/blueprints/browser/specification.py' |
| 810 | --- lib/lp/blueprints/browser/specification.py 2012-05-17 07:46:56 +0000 |
| 811 | +++ lib/lp/blueprints/browser/specification.py 2012-07-03 08:07:22 +0000 |
| 812 | @@ -1307,7 +1307,7 @@ |
| 813 | try: |
| 814 | image = self.renderGraphvizGraph('png') |
| 815 | self.request.response.setHeader('Content-type', 'image/png') |
| 816 | - except (ProblemRenderingGraph, OSError), error: |
| 817 | + except (ProblemRenderingGraph, OSError) as error: |
| 818 | # The subprocess or command can raise errors that might not |
| 819 | # occur if we used a Python bindings for GraphViz. Instead of |
| 820 | # sending the generated image, return the fail-over image |
| 821 | @@ -1327,7 +1327,7 @@ |
| 822 | """Render the image and image map tags for this dependency graph.""" |
| 823 | try: |
| 824 | image_map = self.renderGraphvizGraph('cmapx').decode('UTF-8') |
| 825 | - except (ProblemRenderingGraph, OSError), error: |
| 826 | + except (ProblemRenderingGraph, OSError) as error: |
| 827 | # The subprocess or command can raise errors that might not |
| 828 | # occur if we used a Python bindings for GraphViz. Instead |
| 829 | # of rendering an image map, return an explanation that the |
| 830 | |
| 831 | === modified file 'lib/lp/bugs/adapters/treelookup.py' |
| 832 | --- lib/lp/bugs/adapters/treelookup.py 2009-06-25 00:40:31 +0000 |
| 833 | +++ lib/lp/bugs/adapters/treelookup.py 2012-07-03 08:07:22 +0000 |
| 834 | @@ -226,7 +226,7 @@ |
| 835 | elif len(more) >= 1: |
| 836 | try: |
| 837 | return branch.result.find(*more) |
| 838 | - except KeyError, ex: |
| 839 | + except KeyError as ex: |
| 840 | raise KeyError((key,) + ex.args) |
| 841 | else: |
| 842 | raise KeyError(key) |
| 843 | |
| 844 | === modified file 'lib/lp/bugs/browser/bugalsoaffects.py' |
| 845 | --- lib/lp/bugs/browser/bugalsoaffects.py 2012-06-12 16:09:33 +0000 |
| 846 | +++ lib/lp/bugs/browser/bugalsoaffects.py 2012-07-03 08:07:22 +0000 |
| 847 | @@ -712,7 +712,7 @@ |
| 848 | bug_url = data.get('bug_url').strip() |
| 849 | try: |
| 850 | getUtility(IBugWatchSet).extractBugTrackerAndBug(bug_url) |
| 851 | - except NoBugTrackerFound, error: |
| 852 | + except NoBugTrackerFound as error: |
| 853 | getUtility(IBugTrackerSet).ensureBugTracker( |
| 854 | error.base_url, self.user, error.bugtracker_type) |
| 855 | self.next_step = self._next_step |
| 856 | |
| 857 | === modified file 'lib/lp/bugs/browser/bugtarget.py' |
| 858 | --- lib/lp/bugs/browser/bugtarget.py 2012-06-22 05:52:17 +0000 |
| 859 | +++ lib/lp/bugs/browser/bugtarget.py 2012-07-03 08:07:22 +0000 |
| 860 | @@ -1167,7 +1167,7 @@ |
| 861 | """Make sure some keywords are provided.""" |
| 862 | try: |
| 863 | data['title'] = self.widgets['title'].getInputValue() |
| 864 | - except InputErrors, error: |
| 865 | + except InputErrors as error: |
| 866 | self.setFieldError("title", "A summary is required.") |
| 867 | return [error] |
| 868 | |
| 869 | |
| 870 | === modified file 'lib/lp/bugs/browser/widgets/bug.py' |
| 871 | --- lib/lp/bugs/browser/widgets/bug.py 2012-06-28 16:00:11 +0000 |
| 872 | +++ lib/lp/bugs/browser/widgets/bug.py 2012-07-03 08:07:22 +0000 |
| 873 | @@ -103,7 +103,7 @@ |
| 874 | def getInputValue(self): |
| 875 | try: |
| 876 | return self._getInputValue() |
| 877 | - except WidgetInputError, input_error: |
| 878 | + except WidgetInputError as input_error: |
| 879 | # The standard error message isn't useful at all. We look to |
| 880 | # see if it's a ConstraintNotSatisfied error and change it |
| 881 | # to a better one. For simplicity, we care only about the |
| 882 | |
| 883 | === modified file 'lib/lp/bugs/browser/widgets/bugtask.py' |
| 884 | --- lib/lp/bugs/browser/widgets/bugtask.py 2012-01-01 02:58:52 +0000 |
| 885 | +++ lib/lp/bugs/browser/widgets/bugtask.py 2012-07-03 08:07:22 +0000 |
| 886 | @@ -333,14 +333,14 @@ |
| 887 | bugtask = self.context.context |
| 888 | return bugtask.bug.addWatch( |
| 889 | bugtracker, remote_bug, getUtility(ILaunchBag).user) |
| 890 | - except WidgetInputError, error: |
| 891 | + except WidgetInputError as error: |
| 892 | # Prefix the error with the widget name, since the error |
| 893 | # will be display at the top of the page, and not right |
| 894 | # next to the widget. |
| 895 | raise WidgetInputError( |
| 896 | self.context.__name__, self.label, |
| 897 | 'Remote Bug: %s' % error.doc()) |
| 898 | - except (NoBugTrackerFound, UnrecognizedBugTrackerURL), error: |
| 899 | + except (NoBugTrackerFound, UnrecognizedBugTrackerURL) as error: |
| 900 | raise WidgetInputError( |
| 901 | self.context.__name__, self.label, |
| 902 | 'Invalid bug tracker URL.') |
| 903 | |
| 904 | === modified file 'lib/lp/bugs/externalbugtracker/base.py' |
| 905 | --- lib/lp/bugs/externalbugtracker/base.py 2012-01-01 02:58:52 +0000 |
| 906 | +++ lib/lp/bugs/externalbugtracker/base.py 2012-07-03 08:07:22 +0000 |
| 907 | @@ -245,7 +245,7 @@ |
| 908 | """ |
| 909 | try: |
| 910 | return self.urlopen(page, data) |
| 911 | - except (urllib2.HTTPError, urllib2.URLError), val: |
| 912 | + except (urllib2.HTTPError, urllib2.URLError) as val: |
| 913 | raise BugTrackerConnectError(self.baseurl, val) |
| 914 | |
| 915 | def _getPage(self, page): |
| 916 | |
| 917 | === modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py' |
| 918 | --- lib/lp/bugs/externalbugtracker/bugzilla.py 2012-01-06 11:08:30 +0000 |
| 919 | +++ lib/lp/bugs/externalbugtracker/bugzilla.py 2012-07-03 08:07:22 +0000 |
| 920 | @@ -88,7 +88,7 @@ |
| 921 | # We try calling Bugzilla.version() on the remote |
| 922 | # server because it's the most lightweight method there is. |
| 923 | remote_version = proxy.Bugzilla.version() |
| 924 | - except xmlrpclib.Fault, fault: |
| 925 | + except xmlrpclib.Fault as fault: |
| 926 | # 'Client' is a hangover. Either Bugzilla or the Perl |
| 927 | # XML-RPC lib in use returned it as faultCode. It's wrong, |
| 928 | # but it's known wrongness, so we recognize it here. |
| 929 | @@ -96,7 +96,7 @@ |
| 930 | return False |
| 931 | else: |
| 932 | raise |
| 933 | - except xmlrpclib.ProtocolError, error: |
| 934 | + except xmlrpclib.ProtocolError as error: |
| 935 | # We catch 404s, which occur when xmlrpc.cgi doesn't exist |
| 936 | # on the remote server, and 500s, which sometimes occur when |
| 937 | # an invalid request is made to the remote server. We allow |
| 938 | @@ -130,7 +130,7 @@ |
| 939 | # We try calling Launchpad.plugin_version() on the remote |
| 940 | # server because it's the most lightweight method there is. |
| 941 | proxy.Launchpad.plugin_version() |
| 942 | - except xmlrpclib.Fault, fault: |
| 943 | + except xmlrpclib.Fault as fault: |
| 944 | # 'Client' is a hangover. Either Bugzilla or the Perl |
| 945 | # XML-RPC lib in use returned it as faultCode. It's wrong, |
| 946 | # but it's known wrongness, so we recognize it here. |
| 947 | @@ -138,7 +138,7 @@ |
| 948 | return False |
| 949 | else: |
| 950 | raise |
| 951 | - except xmlrpclib.ProtocolError, error: |
| 952 | + except xmlrpclib.ProtocolError as error: |
| 953 | # We catch 404s, which occur when xmlrpc.cgi doesn't exist |
| 954 | # on the remote server, and 500s, which sometimes occur when |
| 955 | # the Launchpad Plugin isn't installed. Everything else we |
| 956 | @@ -200,7 +200,7 @@ |
| 957 | version_xml = self._getPage('xml.cgi?id=1') |
| 958 | try: |
| 959 | document = self._parseDOMString(version_xml) |
| 960 | - except xml.parsers.expat.ExpatError, e: |
| 961 | + except xml.parsers.expat.ExpatError as e: |
| 962 | raise BugTrackerConnectError(self.baseurl, |
| 963 | "Failed to parse output when probing for version: %s" % e) |
| 964 | bugzilla = document.getElementsByTagName("bugzilla") |
| 965 | @@ -403,7 +403,7 @@ |
| 966 | |
| 967 | try: |
| 968 | document = self._parseDOMString(buglist_xml) |
| 969 | - except xml.parsers.expat.ExpatError, e: |
| 970 | + except xml.parsers.expat.ExpatError as e: |
| 971 | raise UnparsableBugData( |
| 972 | "Failed to parse XML description for %s bugs %s: %s" |
| 973 | % (self.baseurl, bug_ids, e)) |
| 974 | @@ -533,7 +533,7 @@ |
| 975 | def decorator(self, *args, **kwargs): |
| 976 | try: |
| 977 | return func(self, *args, **kwargs) |
| 978 | - except xmlrpclib.Fault, fault: |
| 979 | + except xmlrpclib.Fault as fault: |
| 980 | # Catch authentication errors only. |
| 981 | if fault.faultCode != 410: |
| 982 | raise |
| 983 | @@ -604,7 +604,7 @@ |
| 984 | """ |
| 985 | try: |
| 986 | self.xmlrpc_proxy.User.login(self.credentials) |
| 987 | - except xmlrpclib.Fault, fault: |
| 988 | + except xmlrpclib.Fault as fault: |
| 989 | raise BugTrackerAuthenticationError( |
| 990 | self.baseurl, |
| 991 | "Fault %s: %s" % (fault.faultCode, fault.faultString)) |
| 992 | @@ -934,12 +934,12 @@ |
| 993 | try: |
| 994 | self.xmlrpc_proxy.Launchpad.login( |
| 995 | {'token': token_text}) |
| 996 | - except xmlrpclib.Fault, fault: |
| 997 | + except xmlrpclib.Fault as fault: |
| 998 | message = 'XML-RPC Fault: %s "%s"' % ( |
| 999 | fault.faultCode, fault.faultString) |
| 1000 | raise BugTrackerAuthenticationError( |
| 1001 | self.baseurl, message) |
| 1002 | - except xmlrpclib.ProtocolError, error: |
| 1003 | + except xmlrpclib.ProtocolError as error: |
| 1004 | message = 'Protocol error: %s "%s"' % ( |
| 1005 | error.errcode, error.errmsg) |
| 1006 | raise BugTrackerAuthenticationError( |
| 1007 | |
| 1008 | === modified file 'lib/lp/bugs/externalbugtracker/mantis.py' |
| 1009 | --- lib/lp/bugs/externalbugtracker/mantis.py 2012-01-06 11:08:30 +0000 |
| 1010 | +++ lib/lp/bugs/externalbugtracker/mantis.py 2012-07-03 08:07:22 +0000 |
| 1011 | @@ -159,7 +159,7 @@ |
| 1012 | if bug is not None: |
| 1013 | bugs[bug['id']] = bug |
| 1014 | return bugs |
| 1015 | - except csv.Error, error: |
| 1016 | + except csv.Error as error: |
| 1017 | raise UnparsableBugData("Exception parsing CSV file: %s." % error) |
| 1018 | |
| 1019 | |
| 1020 | @@ -254,7 +254,7 @@ |
| 1021 | # what's being viewed. |
| 1022 | try: |
| 1023 | csv_data = self._getPage("csv_export.php") |
| 1024 | - except BugTrackerConnectError, value: |
| 1025 | + except BugTrackerConnectError as value: |
| 1026 | # Some Mantis installations simply return a 500 error |
| 1027 | # when the csv_export.php page is accessed. Since the |
| 1028 | # bug data may be nevertheless available from ordinary |
| 1029 | |
| 1030 | === modified file 'lib/lp/bugs/externalbugtracker/rt.py' |
| 1031 | --- lib/lp/bugs/externalbugtracker/rt.py 2012-01-01 02:58:52 +0000 |
| 1032 | +++ lib/lp/bugs/externalbugtracker/rt.py 2012-07-03 08:07:22 +0000 |
| 1033 | @@ -85,7 +85,7 @@ |
| 1034 | # can't. |
| 1035 | try: |
| 1036 | self._logIn(opener) |
| 1037 | - except (urllib2.HTTPError, urllib2.URLError), error: |
| 1038 | + except (urllib2.HTTPError, urllib2.URLError) as error: |
| 1039 | raise BugTrackerConnectError('%s/' % self.baseurl, |
| 1040 | "Unable to authenticate with remote RT service: " |
| 1041 | "Could not submit login form: " + |
| 1042 | @@ -110,7 +110,7 @@ |
| 1043 | query_url = '%s/%s' % (self.baseurl, ticket_url) |
| 1044 | try: |
| 1045 | bug_data = self.urlopen(query_url) |
| 1046 | - except urllib2.HTTPError, error: |
| 1047 | + except urllib2.HTTPError as error: |
| 1048 | raise BugTrackerConnectError(ticket_url, error.message) |
| 1049 | |
| 1050 | # We use the first line of the response to ensure that we've |
| 1051 | @@ -146,7 +146,7 @@ |
| 1052 | try: |
| 1053 | bug_data = self.urlopen(query_url, urllib.urlencode( |
| 1054 | request_params)) |
| 1055 | - except urllib2.HTTPError, error: |
| 1056 | + except urllib2.HTTPError as error: |
| 1057 | raise BugTrackerConnectError(query_url, error.message) |
| 1058 | |
| 1059 | # We use the first line of the response to ensure that we've |
| 1060 | |
| 1061 | === modified file 'lib/lp/bugs/externalbugtracker/trac.py' |
| 1062 | --- lib/lp/bugs/externalbugtracker/trac.py 2012-01-01 02:58:52 +0000 |
| 1063 | +++ lib/lp/bugs/externalbugtracker/trac.py 2012-07-03 08:07:22 +0000 |
| 1064 | @@ -70,14 +70,14 @@ |
| 1065 | auth_url = urlappend(base_auth_url, 'check') |
| 1066 | try: |
| 1067 | response = self.urlopen(auth_url) |
| 1068 | - except urllib2.HTTPError, error: |
| 1069 | + except urllib2.HTTPError as error: |
| 1070 | # If the error is HTTP 401 Unauthorized then we're |
| 1071 | # probably talking to the LP plugin. |
| 1072 | if error.code == 401: |
| 1073 | return TracLPPlugin(self.baseurl) |
| 1074 | else: |
| 1075 | return self |
| 1076 | - except urllib2.URLError, error: |
| 1077 | + except urllib2.URLError as error: |
| 1078 | return self |
| 1079 | else: |
| 1080 | # If the response contains a trac_auth cookie then we're |
| 1081 | @@ -301,7 +301,7 @@ |
| 1082 | def decorator(self, *args, **kwargs): |
| 1083 | try: |
| 1084 | return func(self, *args, **kwargs) |
| 1085 | - except xmlrpclib.ProtocolError, error: |
| 1086 | + except xmlrpclib.ProtocolError as error: |
| 1087 | # Catch authentication errors only. |
| 1088 | if error.errcode != 403: |
| 1089 | raise |
| 1090 | @@ -376,7 +376,7 @@ |
| 1091 | |
| 1092 | try: |
| 1093 | self._fetchPage(auth_url) |
| 1094 | - except BugTrackerConnectError, e: |
| 1095 | + except BugTrackerConnectError as e: |
| 1096 | raise BugTrackerAuthenticationError(self.baseurl, e.error) |
| 1097 | |
| 1098 | @ensure_no_transaction |
| 1099 | @@ -489,7 +489,7 @@ |
| 1100 | try: |
| 1101 | timestamp, lp_bug_id = self._server.launchpad.get_launchpad_bug( |
| 1102 | remote_bug) |
| 1103 | - except xmlrpclib.Fault, fault: |
| 1104 | + except xmlrpclib.Fault as fault: |
| 1105 | # Deal with "Ticket does not exist" faults. We re-raise |
| 1106 | # anything else, since they're a sign of a bigger problem. |
| 1107 | if fault.faultCode == FAULT_TICKET_NOT_FOUND: |
| 1108 | @@ -520,7 +520,7 @@ |
| 1109 | try: |
| 1110 | self._server.launchpad.set_launchpad_bug( |
| 1111 | remote_bug, launchpad_bug_id) |
| 1112 | - except xmlrpclib.Fault, fault: |
| 1113 | + except xmlrpclib.Fault as fault: |
| 1114 | # Deal with "Ticket does not exist" faults. We re-raise |
| 1115 | # anything else, since they're a sign of a bigger problem. |
| 1116 | if fault.faultCode == FAULT_TICKET_NOT_FOUND: |
| 1117 | |
| 1118 | === modified file 'lib/lp/bugs/externalbugtracker/xmlrpc.py' |
| 1119 | --- lib/lp/bugs/externalbugtracker/xmlrpc.py 2012-06-28 10:41:18 +0000 |
| 1120 | +++ lib/lp/bugs/externalbugtracker/xmlrpc.py 2012-07-03 08:07:22 +0000 |
| 1121 | @@ -109,7 +109,7 @@ |
| 1122 | request = Request(url, request_body, headers) |
| 1123 | try: |
| 1124 | response = self.opener.open(request).read() |
| 1125 | - except HTTPError, he: |
| 1126 | + except HTTPError as he: |
| 1127 | raise ProtocolError( |
| 1128 | request.get_full_url(), he.code, he.msg, he.hdrs) |
| 1129 | else: |
| 1130 | |
| 1131 | === modified file 'lib/lp/bugs/mail/commands.py' |
| 1132 | --- lib/lp/bugs/mail/commands.py 2012-06-20 11:57:08 +0000 |
| 1133 | +++ lib/lp/bugs/mail/commands.py 2012-07-03 08:07:22 +0000 |
| 1134 | @@ -433,7 +433,7 @@ |
| 1135 | duplicate_field = IBug['duplicateof'].bind(context) |
| 1136 | try: |
| 1137 | duplicate_field.validate(bug) |
| 1138 | - except ValidationError, error: |
| 1139 | + except ValidationError as error: |
| 1140 | raise EmailProcessingError(error.doc()) |
| 1141 | |
| 1142 | context_snapshot = Snapshot( |
| 1143 | @@ -592,7 +592,7 @@ |
| 1144 | stop_processing=True) |
| 1145 | try: |
| 1146 | bug_target = self.getBugTarget(path) |
| 1147 | - except BugTargetNotFound, error: |
| 1148 | + except BugTargetNotFound as error: |
| 1149 | raise EmailProcessingError(unicode(error), stop_processing=True) |
| 1150 | event = None |
| 1151 | |
| 1152 | |
| 1153 | === modified file 'lib/lp/bugs/mail/handler.py' |
| 1154 | --- lib/lp/bugs/mail/handler.py 2012-06-20 08:15:51 +0000 |
| 1155 | +++ lib/lp/bugs/mail/handler.py 2012-07-03 08:07:22 +0000 |
| 1156 | @@ -302,7 +302,7 @@ |
| 1157 | bugtask, bugtask_event = command.execute( |
| 1158 | bugtask, bugtask_event) |
| 1159 | |
| 1160 | - except EmailProcessingError, error: |
| 1161 | + except EmailProcessingError as error: |
| 1162 | processing_errors.append((error, command)) |
| 1163 | if error.stop_processing: |
| 1164 | commands = [] |
| 1165 | @@ -321,7 +321,7 @@ |
| 1166 | self.notify_bug_event(bug_event) |
| 1167 | self.notify_bugtask_event(bugtask_event, bug_event) |
| 1168 | |
| 1169 | - except IncomingEmailError, error: |
| 1170 | + except IncomingEmailError as error: |
| 1171 | send_process_error_notification( |
| 1172 | str(getUtility(ILaunchBag).user.preferredemail.email), |
| 1173 | 'Submit Request Failure', |
| 1174 | |
| 1175 | === modified file 'lib/lp/bugs/model/bug.py' |
| 1176 | --- lib/lp/bugs/model/bug.py 2012-06-29 02:15:05 +0000 |
| 1177 | +++ lib/lp/bugs/model/bug.py 2012-07-03 08:07:22 +0000 |
| 1178 | @@ -1980,7 +1980,7 @@ |
| 1179 | change, empty_recipients, deferred=True) |
| 1180 | |
| 1181 | self.duplicateof = duplicate_of |
| 1182 | - except LaunchpadValidationError, validation_error: |
| 1183 | + except LaunchpadValidationError as validation_error: |
| 1184 | raise InvalidDuplicateValue(validation_error) |
| 1185 | if duplicate_of is not None: |
| 1186 | # Maybe confirm bug tasks, now that more people might be affected |
| 1187 | |
| 1188 | === modified file 'lib/lp/bugs/model/bugtask.py' |
| 1189 | --- lib/lp/bugs/model/bugtask.py 2012-06-29 02:15:05 +0000 |
| 1190 | +++ lib/lp/bugs/model/bugtask.py 2012-07-03 08:07:22 +0000 |
| 1191 | @@ -383,7 +383,7 @@ |
| 1192 | try: |
| 1193 | target.distribution.guessPublishedSourcePackageName( |
| 1194 | target.sourcepackagename.name) |
| 1195 | - except NotFoundError, e: |
| 1196 | + except NotFoundError as e: |
| 1197 | raise IllegalTarget(e[0]) |
| 1198 | |
| 1199 | if bug.information_type == InformationType.PROPRIETARY: |
| 1200 | |
| 1201 | === modified file 'lib/lp/bugs/model/bugwatch.py' |
| 1202 | --- lib/lp/bugs/model/bugwatch.py 2012-02-23 23:37:16 +0000 |
| 1203 | +++ lib/lp/bugs/model/bugwatch.py 2012-07-03 08:07:22 +0000 |
| 1204 | @@ -432,7 +432,7 @@ |
| 1205 | for url in matches: |
| 1206 | try: |
| 1207 | bugtracker, remotebug = self.extractBugTrackerAndBug(str(url)) |
| 1208 | - except NoBugTrackerFound, error: |
| 1209 | + except NoBugTrackerFound as error: |
| 1210 | # We don't want to auto-create EMAILADDRESS bug trackers |
| 1211 | # based on mailto: URIs in comments. |
| 1212 | if error.bugtracker_type == BugTrackerType.EMAILADDRESS: |
| 1213 | |
| 1214 | === modified file 'lib/lp/bugs/scripts/bugimport.py' |
| 1215 | --- lib/lp/bugs/scripts/bugimport.py 2012-06-13 21:40:11 +0000 |
| 1216 | +++ lib/lp/bugs/scripts/bugimport.py 2012-07-03 08:07:22 +0000 |
| 1217 | @@ -351,7 +351,7 @@ |
| 1218 | try: |
| 1219 | bugtracker, remotebug = bugwatchset.extractBugTrackerAndBug( |
| 1220 | watchnode.get('href')) |
| 1221 | - except NoBugTrackerFound, exc: |
| 1222 | + except NoBugTrackerFound as exc: |
| 1223 | self.logger.debug( |
| 1224 | 'Registering bug tracker for %s', exc.base_url) |
| 1225 | bugtracker = getUtility(IBugTrackerSet).ensureBugTracker( |
| 1226 | |
| 1227 | === modified file 'lib/lp/bugs/scripts/bzremotecomponentfinder.py' |
| 1228 | --- lib/lp/bugs/scripts/bzremotecomponentfinder.py 2012-02-24 01:25:58 +0000 |
| 1229 | +++ lib/lp/bugs/scripts/bzremotecomponentfinder.py 2012-07-03 08:07:22 +0000 |
| 1230 | @@ -150,7 +150,7 @@ |
| 1231 | try: |
| 1232 | self.logger.debug("...Fetching page") |
| 1233 | page_text = bz_bugtracker.getPage() |
| 1234 | - except HTTPError, error: |
| 1235 | + except HTTPError as error: |
| 1236 | self.logger.warning("Could not fetch %s: %s" % ( |
| 1237 | lp_bugtracker.baseurl, error)) |
| 1238 | continue |
| 1239 | |
| 1240 | === modified file 'lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py' |
| 1241 | --- lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py 2012-01-01 02:58:52 +0000 |
| 1242 | +++ lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py 2012-07-03 08:07:22 +0000 |
| 1243 | @@ -89,7 +89,7 @@ |
| 1244 | if self.can_back_link: |
| 1245 | error_status = BugWatchActivityStatus.BACKLINK_FAILED |
| 1246 | self.linkLaunchpadBug() |
| 1247 | - except Exception, ex: |
| 1248 | + except Exception as ex: |
| 1249 | error_message = str(ex) |
| 1250 | log_message = ( |
| 1251 | "Failure updating bug %r on %s (local bug: %s)" % |
| 1252 | |
| 1253 | === modified file 'lib/lp/bugs/scripts/checkwatches/core.py' |
| 1254 | --- lib/lp/bugs/scripts/checkwatches/core.py 2011-12-30 06:14:56 +0000 |
| 1255 | +++ lib/lp/bugs/scripts/checkwatches/core.py 2012-07-03 08:07:22 +0000 |
| 1256 | @@ -121,7 +121,7 @@ |
| 1257 | """ |
| 1258 | try: |
| 1259 | yield |
| 1260 | - except Exception, e: |
| 1261 | + except Exception as e: |
| 1262 | # We record the error against all the bugwatches that should |
| 1263 | # have been updated before re-raising it. We also update the |
| 1264 | # bug watches' lastchecked dates so that checkwatches |
| 1265 | @@ -267,7 +267,7 @@ |
| 1266 | except (KeyboardInterrupt, SystemExit): |
| 1267 | # We should never catch KeyboardInterrupt or SystemExit. |
| 1268 | raise |
| 1269 | - except Exception, error: |
| 1270 | + except Exception as error: |
| 1271 | # If something unexpected goes wrong, we log it and |
| 1272 | # continue: a failure shouldn't break the updating of |
| 1273 | # the other bug trackers. |
| 1274 | @@ -426,7 +426,7 @@ |
| 1275 | try: |
| 1276 | trackers_and_watches = self._getExternalBugTrackersAndWatches( |
| 1277 | bug_tracker, bug_watches_to_update) |
| 1278 | - except (UnknownBugTrackerTypeError, ProtocolError), error: |
| 1279 | + except (UnknownBugTrackerTypeError, ProtocolError) as error: |
| 1280 | # We update all the bug watches to reflect the fact that |
| 1281 | # this error occurred. We also update their last checked |
| 1282 | # date to ensure that they don't get checked for another |
| 1283 | |
| 1284 | === modified file 'lib/lp/bugs/scripts/checkwatches/remotebugupdater.py' |
| 1285 | --- lib/lp/bugs/scripts/checkwatches/remotebugupdater.py 2012-04-16 23:02:44 +0000 |
| 1286 | +++ lib/lp/bugs/scripts/checkwatches/remotebugupdater.py 2012-07-03 08:07:22 +0000 |
| 1287 | @@ -145,7 +145,7 @@ |
| 1288 | self.remote_bug)) |
| 1289 | new_malone_importance = self._convertRemoteImportance( |
| 1290 | new_remote_importance) |
| 1291 | - except (InvalidBugId, BugNotFound, PrivateRemoteBug), ex: |
| 1292 | + except (InvalidBugId, BugNotFound, PrivateRemoteBug) as ex: |
| 1293 | error = get_bugwatcherrortype_for_error(ex) |
| 1294 | message = self.error_type_messages.get( |
| 1295 | error, self.error_type_message_default) |
| 1296 | @@ -170,7 +170,7 @@ |
| 1297 | bug_watch_updater.updateBugWatch( |
| 1298 | new_remote_status, new_malone_status, |
| 1299 | new_remote_importance, new_malone_importance) |
| 1300 | - except Exception, error: |
| 1301 | + except Exception as error: |
| 1302 | # Send the error to the log. |
| 1303 | oops_id = self.error( |
| 1304 | "Failure updating bug %r on %s (local bugs: %s)." % |
| 1305 | @@ -225,7 +225,7 @@ |
| 1306 | |
| 1307 | try: |
| 1308 | launchpad_value = conversion_method(remote_value) |
| 1309 | - except UnknownRemoteValueError, e: |
| 1310 | + except UnknownRemoteValueError as e: |
| 1311 | # We log the warning, since we need to know about values |
| 1312 | # that we don't handle correctly. |
| 1313 | self.logger.info( |
| 1314 | |
| 1315 | === modified file 'lib/lp/bugs/scripts/debbugs.py' |
| 1316 | --- lib/lp/bugs/scripts/debbugs.py 2010-08-20 20:31:18 +0000 |
| 1317 | +++ lib/lp/bugs/scripts/debbugs.py 2012-07-03 08:07:22 +0000 |
| 1318 | @@ -151,14 +151,14 @@ |
| 1319 | |
| 1320 | try: |
| 1321 | fd = open(summary) |
| 1322 | - except IOError, e: |
| 1323 | + except IOError as e: |
| 1324 | if e.errno == 2: |
| 1325 | raise SummaryMissing, summary |
| 1326 | raise |
| 1327 | |
| 1328 | try: |
| 1329 | message = email.message_from_file(fd) |
| 1330 | - except Exception, e: |
| 1331 | + except Exception as e: |
| 1332 | raise SummaryParseError, '%s: %s' % (summary, str(e)) |
| 1333 | |
| 1334 | version = message['format-version'] |
| 1335 | @@ -192,7 +192,7 @@ |
| 1336 | |
| 1337 | try: |
| 1338 | fd = open(report) |
| 1339 | - except IOError, e: |
| 1340 | + except IOError as e: |
| 1341 | if e.errno == 2: |
| 1342 | raise ReportMissing, report |
| 1343 | raise |
| 1344 | @@ -241,7 +241,7 @@ |
| 1345 | if process.returncode != 0: |
| 1346 | raise LogParseFailed(errors) |
| 1347 | |
| 1348 | - except IOError, e: |
| 1349 | + except IOError as e: |
| 1350 | if e.errno == 2: |
| 1351 | raise LogMissing, log |
| 1352 | raise |
| 1353 | @@ -268,7 +268,7 @@ |
| 1354 | for bug in Database('/srv/debzilla.no-name-yet.com/debbugs'): |
| 1355 | try: |
| 1356 | print bug, bug.subject |
| 1357 | - except Exception, e: |
| 1358 | + except Exception as e: |
| 1359 | print >>sys.stderr, '%s: %s' % (e.__class__.__name__, str(e)) |
| 1360 | |
| 1361 | |
| 1362 | |
| 1363 | === modified file 'lib/lp/bugs/scripts/sfremoteproductfinder.py' |
| 1364 | --- lib/lp/bugs/scripts/sfremoteproductfinder.py 2012-01-01 02:58:52 +0000 |
| 1365 | +++ lib/lp/bugs/scripts/sfremoteproductfinder.py 2012-07-03 08:07:22 +0000 |
| 1366 | @@ -55,7 +55,7 @@ |
| 1367 | # First, fetch the project page. |
| 1368 | try: |
| 1369 | soup = BeautifulSoup(self._getPage("projects/%s" % sf_project)) |
| 1370 | - except HTTPError, error: |
| 1371 | + except HTTPError as error: |
| 1372 | self.logger.error( |
| 1373 | "Error fetching project %s: %s" % |
| 1374 | (sf_project, error)) |
| 1375 | @@ -75,7 +75,7 @@ |
| 1376 | tracker_url = tracker_url.lstrip('/') |
| 1377 | try: |
| 1378 | soup = BeautifulSoup(self._getPage(tracker_url)) |
| 1379 | - except HTTPError, error: |
| 1380 | + except HTTPError as error: |
| 1381 | self.logger.error( |
| 1382 | "Error fetching project %s: %s" % |
| 1383 | (sf_project, error)) |
| 1384 | |
| 1385 | === modified file 'lib/lp/bugs/scripts/updateremoteproduct.py' |
| 1386 | --- lib/lp/bugs/scripts/updateremoteproduct.py 2011-12-19 14:54:37 +0000 |
| 1387 | +++ lib/lp/bugs/scripts/updateremoteproduct.py 2012-07-03 08:07:22 +0000 |
| 1388 | @@ -85,7 +85,7 @@ |
| 1389 | # bug 334449 is fixed this part of the except should be |
| 1390 | # removed. |
| 1391 | except (AssertionError, BugWatchUpdateError, |
| 1392 | - BugWatchUpdateWarning), error: |
| 1393 | + BugWatchUpdateWarning) as error: |
| 1394 | self.logger.error( |
| 1395 | "Unable to set remote_product for '%s': %s" % |
| 1396 | (product.name, error)) |
| 1397 | |
| 1398 | === modified file 'lib/lp/bugs/tests/test_bugwatch.py' |
| 1399 | --- lib/lp/bugs/tests/test_bugwatch.py 2012-02-23 23:37:16 +0000 |
| 1400 | +++ lib/lp/bugs/tests/test_bugwatch.py 2012-07-03 08:07:22 +0000 |
| 1401 | @@ -112,7 +112,7 @@ |
| 1402 | try: |
| 1403 | bugtracker, bug = self.bugwatch_set.extractBugTrackerAndBug( |
| 1404 | self.bug_url) |
| 1405 | - except NoBugTrackerFound, error: |
| 1406 | + except NoBugTrackerFound as error: |
| 1407 | # The raised exception should contain enough information so |
| 1408 | # that we can register a new bug tracker. |
| 1409 | self.assertEqual(error.base_url, self.base_url) |
| 1410 | |
| 1411 | === modified file 'lib/lp/bugs/tests/test_duplicate_handling.py' |
| 1412 | --- lib/lp/bugs/tests/test_duplicate_handling.py 2012-04-16 23:02:44 +0000 |
| 1413 | +++ lib/lp/bugs/tests/test_duplicate_handling.py 2012-07-03 08:07:22 +0000 |
| 1414 | @@ -48,7 +48,7 @@ |
| 1415 | def assertDuplicateError(self, bug, duplicateof, msg): |
| 1416 | try: |
| 1417 | bug.markAsDuplicate(duplicateof) |
| 1418 | - except InvalidDuplicateValue, err: |
| 1419 | + except InvalidDuplicateValue as err: |
| 1420 | self.assertEqual(str(err), msg) |
| 1421 | |
| 1422 | def test_error_on_duplicate_to_duplicate(self): |
| 1423 | |
| 1424 | === modified file 'lib/lp/buildmaster/model/builder.py' |
| 1425 | --- lib/lp/buildmaster/model/builder.py 2012-05-23 10:28:40 +0000 |
| 1426 | +++ lib/lp/buildmaster/model/builder.py 2012-07-03 08:07:22 +0000 |
| 1427 | @@ -372,7 +372,7 @@ |
| 1428 | slave_build_id = status_sentence[ident_position[status]] |
| 1429 | try: |
| 1430 | builder.verifySlaveBuildCookie(slave_build_id) |
| 1431 | - except CorruptBuildCookie, reason: |
| 1432 | + except CorruptBuildCookie as reason: |
| 1433 | if status == 'BuilderStatus.WAITING': |
| 1434 | d = builder.cleanSlave() |
| 1435 | else: |
| 1436 | |
| 1437 | === modified file 'lib/lp/code/browser/branch.py' |
| 1438 | --- lib/lp/code/browser/branch.py 2012-06-22 05:52:17 +0000 |
| 1439 | +++ lib/lp/code/browser/branch.py 2012-07-03 08:07:22 +0000 |
| 1440 | @@ -1120,7 +1120,7 @@ |
| 1441 | self.addError( |
| 1442 | "%s is not allowed to own branches in %s." % ( |
| 1443 | owner.displayname, self.context.target.displayname)) |
| 1444 | - except BranchExists, e: |
| 1445 | + except BranchExists as e: |
| 1446 | self._setBranchExists(e.existing_branch) |
| 1447 | |
| 1448 | # If the branch is a MIRRORED branch, then the url |
| 1449 | @@ -1317,7 +1317,7 @@ |
| 1450 | return None |
| 1451 | else: |
| 1452 | self.next_url = canonical_url(proposal) |
| 1453 | - except InvalidBranchMergeProposal, error: |
| 1454 | + except InvalidBranchMergeProposal as error: |
| 1455 | self.addError(str(error)) |
| 1456 | |
| 1457 | def validate(self, data): |
| 1458 | @@ -1373,7 +1373,7 @@ |
| 1459 | except CodeImportAlreadyRunning: |
| 1460 | self.request.response.addNotification( |
| 1461 | "The import is already running.") |
| 1462 | - except CodeImportAlreadyRequested, e: |
| 1463 | + except CodeImportAlreadyRequested as e: |
| 1464 | user = e.requesting_user |
| 1465 | adapter = queryAdapter(user, IPathAdapter, 'fmt') |
| 1466 | self.request.response.addNotification( |
| 1467 | |
| 1468 | === modified file 'lib/lp/code/browser/codeimport.py' |
| 1469 | --- lib/lp/code/browser/codeimport.py 2012-02-28 01:22:50 +0000 |
| 1470 | +++ lib/lp/code/browser/codeimport.py 2012-07-03 08:07:22 +0000 |
| 1471 | @@ -426,7 +426,7 @@ |
| 1472 | """Create the code_import, and subscribe the user to the branch.""" |
| 1473 | try: |
| 1474 | code_import = self._create_import(data, None) |
| 1475 | - except BranchExists, e: |
| 1476 | + except BranchExists as e: |
| 1477 | self._setBranchExists(e.existing_branch) |
| 1478 | return |
| 1479 | |
| 1480 | |
| 1481 | === modified file 'lib/lp/code/browser/codereviewvote.py' |
| 1482 | --- lib/lp/code/browser/codereviewvote.py 2012-01-01 02:58:52 +0000 |
| 1483 | +++ lib/lp/code/browser/codereviewvote.py 2012-07-03 08:07:22 +0000 |
| 1484 | @@ -53,5 +53,5 @@ |
| 1485 | if reviewer is not None: |
| 1486 | try: |
| 1487 | self.context.validateReasignReview(reviewer) |
| 1488 | - except (ReviewNotPending, UserHasExistingReview), e: |
| 1489 | + except (ReviewNotPending, UserHasExistingReview) as e: |
| 1490 | self.addError(str(e)) |
| 1491 | |
| 1492 | === modified file 'lib/lp/code/browser/sourcepackagerecipe.py' |
| 1493 | --- lib/lp/code/browser/sourcepackagerecipe.py 2012-06-15 16:23:50 +0000 |
| 1494 | +++ lib/lp/code/browser/sourcepackagerecipe.py 2012-07-03 08:07:22 +0000 |
| 1495 | @@ -434,7 +434,7 @@ |
| 1496 | build = self.context.requestBuild( |
| 1497 | data['archive'], self.user, distroseries, manual=True) |
| 1498 | builds.append(build) |
| 1499 | - except BuildAlreadyPending, e: |
| 1500 | + except BuildAlreadyPending as e: |
| 1501 | existing_message = informational.get("already_pending") |
| 1502 | if existing_message: |
| 1503 | new_message = existing_message[:-1] + ( |
| 1504 | @@ -636,7 +636,7 @@ |
| 1505 | try: |
| 1506 | parser = RecipeParser(data['recipe_text']) |
| 1507 | parser.parse() |
| 1508 | - except RecipeParseError, error: |
| 1509 | + except RecipeParseError as error: |
| 1510 | self.setFieldError('recipe_text', str(error)) |
| 1511 | |
| 1512 | def error_handler(self, callable, *args, **kwargs): |
| 1513 | @@ -646,15 +646,15 @@ |
| 1514 | self.setFieldError( |
| 1515 | 'recipe_text', |
| 1516 | 'The recipe format version specified is not available.') |
| 1517 | - except ForbiddenInstructionError, e: |
| 1518 | + except ForbiddenInstructionError as e: |
| 1519 | self.setFieldError( |
| 1520 | 'recipe_text', |
| 1521 | 'The bzr-builder instruction "%s" is not permitted ' |
| 1522 | 'here.' % e.instruction_name) |
| 1523 | - except NoSuchBranch, e: |
| 1524 | + except NoSuchBranch as e: |
| 1525 | self.setFieldError( |
| 1526 | 'recipe_text', '%s is not a branch on Launchpad.' % e.name) |
| 1527 | - except PrivateBranchRecipe, e: |
| 1528 | + except PrivateBranchRecipe as e: |
| 1529 | self.setFieldError('recipe_text', str(e)) |
| 1530 | raise ErrorHandled() |
| 1531 | |
| 1532 | |
| 1533 | === modified file 'lib/lp/code/interfaces/codeimport.py' |
| 1534 | --- lib/lp/code/interfaces/codeimport.py 2012-02-28 01:22:50 +0000 |
| 1535 | +++ lib/lp/code/interfaces/codeimport.py 2012-07-03 08:07:22 +0000 |
| 1536 | @@ -54,7 +54,7 @@ |
| 1537 | def validate_cvs_root(cvsroot): |
| 1538 | try: |
| 1539 | root = CVSRoot(cvsroot) |
| 1540 | - except CvsRootError, e: |
| 1541 | + except CvsRootError as e: |
| 1542 | raise LaunchpadValidationError(e) |
| 1543 | if root.method == 'local': |
| 1544 | raise LaunchpadValidationError('Local CVS roots are not allowed.') |
| 1545 | |
| 1546 | === modified file 'lib/lp/code/mail/codehandler.py' |
| 1547 | --- lib/lp/code/mail/codehandler.py 2012-06-20 08:15:51 +0000 |
| 1548 | +++ lib/lp/code/mail/codehandler.py 2012-07-03 08:07:22 +0000 |
| 1549 | @@ -266,7 +266,7 @@ |
| 1550 | for command in commands: |
| 1551 | try: |
| 1552 | command.execute(context) |
| 1553 | - except EmailProcessingError, error: |
| 1554 | + except EmailProcessingError as error: |
| 1555 | processing_errors.append((error, command)) |
| 1556 | |
| 1557 | if len(processing_errors) > 0: |
| 1558 | @@ -315,7 +315,7 @@ |
| 1559 | merge_proposal.createCommentFromMessage( |
| 1560 | message, context.vote, context.vote_tags, mail) |
| 1561 | |
| 1562 | - except IncomingEmailError, error: |
| 1563 | + except IncomingEmailError as error: |
| 1564 | send_process_error_notification( |
| 1565 | str(user.preferredemail.email), |
| 1566 | 'Submit Request Failure', |
| 1567 | |
| 1568 | === modified file 'lib/lp/code/model/sourcepackagerecipebuild.py' |
| 1569 | --- lib/lp/code/model/sourcepackagerecipebuild.py 2012-04-24 06:37:38 +0000 |
| 1570 | +++ lib/lp/code/model/sourcepackagerecipebuild.py 2012-07-03 08:07:22 +0000 |
| 1571 | @@ -225,7 +225,7 @@ |
| 1572 | logger.debug( |
| 1573 | ' - build already pending for %s', series_name) |
| 1574 | continue |
| 1575 | - except CannotUploadToArchive, e: |
| 1576 | + except CannotUploadToArchive as e: |
| 1577 | # This will catch all PPA related issues - |
| 1578 | # disabled, security, wrong pocket etc |
| 1579 | logger.debug( |
| 1580 | |
| 1581 | === modified file 'lib/lp/code/model/tests/test_codeimportjob.py' |
| 1582 | --- lib/lp/code/model/tests/test_codeimportjob.py 2011-12-30 06:14:56 +0000 |
| 1583 | +++ lib/lp/code/model/tests/test_codeimportjob.py 2012-07-03 08:07:22 +0000 |
| 1584 | @@ -310,7 +310,7 @@ |
| 1585 | """ |
| 1586 | try: |
| 1587 | callable_obj(*args, **kwargs) |
| 1588 | - except AssertionError, exception: |
| 1589 | + except AssertionError as exception: |
| 1590 | self.assertEqual(str(exception), message) |
| 1591 | else: |
| 1592 | self.fail("AssertionError was not raised") |
| 1593 | |
| 1594 | === modified file 'lib/lp/code/xmlrpc/branch.py' |
| 1595 | --- lib/lp/code/xmlrpc/branch.py 2012-01-01 02:58:52 +0000 |
| 1596 | +++ lib/lp/code/xmlrpc/branch.py 2012-07-03 08:07:22 +0000 |
| 1597 | @@ -127,7 +127,7 @@ |
| 1598 | try: |
| 1599 | unicode_branch_url = branch_url.decode('utf-8') |
| 1600 | IBranch['url'].validate(unicode_branch_url) |
| 1601 | - except LaunchpadValidationError, exc: |
| 1602 | + except LaunchpadValidationError as exc: |
| 1603 | return faults.InvalidBranchUrl(branch_url, exc) |
| 1604 | |
| 1605 | # We want it to be None in the database, not ''. |
| 1606 | @@ -154,9 +154,9 @@ |
| 1607 | branch.requestMirror() |
| 1608 | except BranchCreationForbidden: |
| 1609 | return faults.BranchCreationForbidden(product.displayname) |
| 1610 | - except BranchCreationException, err: |
| 1611 | + except BranchCreationException as err: |
| 1612 | return faults.BranchNameInUse(err) |
| 1613 | - except LaunchpadValidationError, err: |
| 1614 | + except LaunchpadValidationError as err: |
| 1615 | return faults.InvalidBranchName(err) |
| 1616 | |
| 1617 | return canonical_url(branch) |
| 1618 | @@ -303,24 +303,24 @@ |
| 1619 | # and thus error prone. Alternatives are directly raising faults from |
| 1620 | # the model code(blech) or some automated way of reraising as faults |
| 1621 | # or using a narrower range of faults (e.g. only one "NoSuch" fault). |
| 1622 | - except InvalidProductName, e: |
| 1623 | + except InvalidProductName as e: |
| 1624 | raise faults.InvalidProductIdentifier(urlutils.escape(e.name)) |
| 1625 | - except NoSuchProductSeries, e: |
| 1626 | + except NoSuchProductSeries as e: |
| 1627 | raise faults.NoSuchProductSeries( |
| 1628 | urlutils.escape(e.name), e.product) |
| 1629 | - except NoSuchPerson, e: |
| 1630 | + except NoSuchPerson as e: |
| 1631 | raise faults.NoSuchPersonWithName(urlutils.escape(e.name)) |
| 1632 | - except NoSuchProduct, e: |
| 1633 | + except NoSuchProduct as e: |
| 1634 | raise faults.NoSuchProduct(urlutils.escape(e.name)) |
| 1635 | - except NoSuchDistroSeries, e: |
| 1636 | + except NoSuchDistroSeries as e: |
| 1637 | raise faults.NoSuchDistroSeries(urlutils.escape(e.name)) |
| 1638 | - except NoSuchSourcePackageName, e: |
| 1639 | + except NoSuchSourcePackageName as e: |
| 1640 | raise faults.NoSuchSourcePackageName(urlutils.escape(e.name)) |
| 1641 | - except NoLinkedBranch, e: |
| 1642 | + except NoLinkedBranch as e: |
| 1643 | raise faults.NoLinkedBranch(e.component) |
| 1644 | - except CannotHaveLinkedBranch, e: |
| 1645 | + except CannotHaveLinkedBranch as e: |
| 1646 | raise faults.CannotHaveLinkedBranch(e.component) |
| 1647 | - except InvalidNamespace, e: |
| 1648 | + except InvalidNamespace as e: |
| 1649 | raise faults.InvalidBranchUniqueName(urlutils.escape(e.name)) |
| 1650 | # Reverse engineer the actual lp_path that is used, so we need to |
| 1651 | # remove any suffix that may be there from the strip_path. |
| 1652 | |
| 1653 | === modified file 'lib/lp/code/xmlrpc/codehosting.py' |
| 1654 | --- lib/lp/code/xmlrpc/codehosting.py 2012-01-01 02:58:52 +0000 |
| 1655 | +++ lib/lp/code/xmlrpc/codehosting.py 2012-07-03 08:07:22 +0000 |
| 1656 | @@ -219,10 +219,10 @@ |
| 1657 | except InvalidNamespace: |
| 1658 | return faults.PermissionDenied( |
| 1659 | "Cannot create branch at '%s'" % branch_path) |
| 1660 | - except NoSuchPerson, e: |
| 1661 | + except NoSuchPerson as e: |
| 1662 | return faults.NotFound( |
| 1663 | "User/team '%s' does not exist." % e.name) |
| 1664 | - except NoSuchProduct, e: |
| 1665 | + except NoSuchProduct as e: |
| 1666 | return faults.NotFound( |
| 1667 | "Project '%s' does not exist." % e.name) |
| 1668 | except NoSuchSourcePackageName as e: |
| 1669 | @@ -231,17 +231,17 @@ |
| 1670 | except InvalidName: |
| 1671 | return faults.InvalidSourcePackageName(e.name) |
| 1672 | return self.createBranch(login_id, branch_path) |
| 1673 | - except NameLookupFailed, e: |
| 1674 | + except NameLookupFailed as e: |
| 1675 | return faults.NotFound(str(e)) |
| 1676 | try: |
| 1677 | branch = namespace.createBranch( |
| 1678 | BranchType.HOSTED, branch_name, requester) |
| 1679 | - except LaunchpadValidationError, e: |
| 1680 | + except LaunchpadValidationError as e: |
| 1681 | msg = e.args[0] |
| 1682 | if isinstance(msg, unicode): |
| 1683 | msg = msg.encode('utf-8') |
| 1684 | return faults.PermissionDenied(msg) |
| 1685 | - except BranchCreationException, e: |
| 1686 | + except BranchCreationException as e: |
| 1687 | return faults.PermissionDenied(str(e)) |
| 1688 | |
| 1689 | if link_func: |
| 1690 | |
| 1691 | === modified file 'lib/lp/codehosting/codeimport/tests/helpers.py' |
| 1692 | --- lib/lp/codehosting/codeimport/tests/helpers.py 2009-06-25 04:06:00 +0000 |
| 1693 | +++ lib/lp/codehosting/codeimport/tests/helpers.py 2012-07-03 08:07:22 +0000 |
| 1694 | @@ -31,7 +31,7 @@ |
| 1695 | self.observer.called(self.name, args, kwargs) |
| 1696 | try: |
| 1697 | value = self.callable(*args, **kwargs) |
| 1698 | - except Exception, exc: |
| 1699 | + except Exception as exc: |
| 1700 | self.observer.raised(self.name, exc) |
| 1701 | raise |
| 1702 | else: |
| 1703 | |
| 1704 | === modified file 'lib/lp/codehosting/codeimport/tests/servers.py' |
| 1705 | --- lib/lp/codehosting/codeimport/tests/servers.py 2011-09-01 21:00:42 +0000 |
| 1706 | +++ lib/lp/codehosting/codeimport/tests/servers.py 2012-07-03 08:07:22 +0000 |
| 1707 | @@ -127,7 +127,7 @@ |
| 1708 | for i in range(10): |
| 1709 | try: |
| 1710 | self._get_ra(self.get_url()) |
| 1711 | - except OSError, e: |
| 1712 | + except OSError as e: |
| 1713 | if e.errno == errno.ECONNREFUSED: |
| 1714 | time.sleep(delay) |
| 1715 | delay *= 1.5 |
| 1716 | |
| 1717 | === modified file 'lib/lp/codehosting/codeimport/worker.py' |
| 1718 | --- lib/lp/codehosting/codeimport/worker.py 2012-02-27 23:59:14 +0000 |
| 1719 | +++ lib/lp/codehosting/codeimport/worker.py 2012-07-03 08:07:22 +0000 |
| 1720 | @@ -731,10 +731,10 @@ |
| 1721 | except NotBranchError: |
| 1722 | self._logger.info("No branch found at remote location.") |
| 1723 | return CodeImportWorkerExitCode.FAILURE_INVALID |
| 1724 | - except BadUrl, e: |
| 1725 | + except BadUrl as e: |
| 1726 | self._logger.info("Invalid URL: %s" % e) |
| 1727 | return CodeImportWorkerExitCode.FAILURE_FORBIDDEN |
| 1728 | - except ConnectionError, e: |
| 1729 | + except ConnectionError as e: |
| 1730 | self._logger.info("Unable to open remote branch: %s" % e) |
| 1731 | return CodeImportWorkerExitCode.FAILURE_INVALID |
| 1732 | try: |
| 1733 | @@ -751,7 +751,7 @@ |
| 1734 | result = CodeImportWorkerExitCode.SUCCESS_NOCHANGE |
| 1735 | else: |
| 1736 | result = CodeImportWorkerExitCode.SUCCESS_PARTIAL |
| 1737 | - except Exception, e: |
| 1738 | + except Exception as e: |
| 1739 | if e.__class__ in self.unsupported_feature_exceptions: |
| 1740 | self._logger.info( |
| 1741 | "Unable to import branch because of limitations in " |
| 1742 | |
| 1743 | === modified file 'lib/lp/codehosting/inmemory.py' |
| 1744 | --- lib/lp/codehosting/inmemory.py 2012-06-01 02:26:43 +0000 |
| 1745 | +++ lib/lp/codehosting/inmemory.py 2012-07-03 08:07:22 +0000 |
| 1746 | @@ -701,9 +701,9 @@ |
| 1747 | registrant = self._person_set.get(requester_id) |
| 1748 | try: |
| 1749 | return self._createBranch(registrant, escaped_path) |
| 1750 | - except LaunchpadFault, e: |
| 1751 | + except LaunchpadFault as e: |
| 1752 | return e |
| 1753 | - except LaunchpadValidationError, e: |
| 1754 | + except LaunchpadValidationError as e: |
| 1755 | msg = e.args[0] |
| 1756 | if isinstance(msg, unicode): |
| 1757 | msg = msg.encode('utf-8') |
| 1758 | |
| 1759 | === modified file 'lib/lp/codehosting/puller/__init__.py' |
| 1760 | --- lib/lp/codehosting/puller/__init__.py 2010-08-20 20:31:18 +0000 |
| 1761 | +++ lib/lp/codehosting/puller/__init__.py 2012-07-03 08:07:22 +0000 |
| 1762 | @@ -25,7 +25,7 @@ |
| 1763 | """Mirror all current branches that need to be mirrored.""" |
| 1764 | try: |
| 1765 | manager.lock() |
| 1766 | - except LockError, exception: |
| 1767 | + except LockError as exception: |
| 1768 | logger.info('Could not acquire lock: %s', exception) |
| 1769 | return defer.succeed(0) |
| 1770 | |
| 1771 | |
| 1772 | === modified file 'lib/lp/codehosting/puller/worker.py' |
| 1773 | --- lib/lp/codehosting/puller/worker.py 2012-04-16 23:02:44 +0000 |
| 1774 | +++ lib/lp/codehosting/puller/worker.py 2012-07-03 08:07:22 +0000 |
| 1775 | @@ -384,7 +384,7 @@ |
| 1776 | # add further encountered errors from the production runs here |
| 1777 | # ------ HERE --------- |
| 1778 | # |
| 1779 | - except urllib2.HTTPError, e: |
| 1780 | + except urllib2.HTTPError as e: |
| 1781 | msg = str(e) |
| 1782 | if int(e.code) == httplib.UNAUTHORIZED: |
| 1783 | # Maybe this will be caught in bzrlib one day, and then we'll |
| 1784 | @@ -393,19 +393,19 @@ |
| 1785 | msg = "Authentication required." |
| 1786 | self._mirrorFailed(msg) |
| 1787 | |
| 1788 | - except socket.error, e: |
| 1789 | + except socket.error as e: |
| 1790 | msg = 'A socket error occurred: %s' % str(e) |
| 1791 | self._mirrorFailed(msg) |
| 1792 | |
| 1793 | - except errors.UnsupportedFormatError, e: |
| 1794 | + except errors.UnsupportedFormatError as e: |
| 1795 | msg = ("Launchpad does not support branches from before " |
| 1796 | "bzr 0.7. Please upgrade the branch using bzr upgrade.") |
| 1797 | self._mirrorFailed(msg) |
| 1798 | |
| 1799 | - except errors.UnknownFormatError, e: |
| 1800 | + except errors.UnknownFormatError as e: |
| 1801 | self._mirrorFailed(e) |
| 1802 | |
| 1803 | - except (errors.ParamikoNotPresent, BadUrlSsh), e: |
| 1804 | + except (errors.ParamikoNotPresent, BadUrlSsh) as e: |
| 1805 | msg = ("Launchpad cannot mirror branches from SFTP and SSH URLs." |
| 1806 | " Please register a HTTP location for this branch.") |
| 1807 | self._mirrorFailed(msg) |
| 1808 | @@ -414,11 +414,11 @@ |
| 1809 | msg = "Launchpad does not mirror branches from Launchpad." |
| 1810 | self._mirrorFailed(msg) |
| 1811 | |
| 1812 | - except BadUrlScheme, e: |
| 1813 | + except BadUrlScheme as e: |
| 1814 | msg = "Launchpad does not mirror %s:// URLs." % e.scheme |
| 1815 | self._mirrorFailed(msg) |
| 1816 | |
| 1817 | - except errors.NotBranchError, e: |
| 1818 | + except errors.NotBranchError as e: |
| 1819 | hosted_branch_error = errors.NotBranchError( |
| 1820 | "lp:%s" % self.unique_name) |
| 1821 | message_by_type = { |
| 1822 | @@ -428,19 +428,19 @@ |
| 1823 | msg = message_by_type.get(self.branch_type, str(e)) |
| 1824 | self._mirrorFailed(msg) |
| 1825 | |
| 1826 | - except BranchReferenceForbidden, e: |
| 1827 | + except BranchReferenceForbidden as e: |
| 1828 | msg = ("Branch references are not allowed for branches of type " |
| 1829 | "%s." % (self.branch_type.title,)) |
| 1830 | self._mirrorFailed(msg) |
| 1831 | |
| 1832 | - except BranchLoopError, e: |
| 1833 | + except BranchLoopError as e: |
| 1834 | msg = "Circular branch reference." |
| 1835 | self._mirrorFailed(msg) |
| 1836 | |
| 1837 | - except errors.BzrError, e: |
| 1838 | + except errors.BzrError as e: |
| 1839 | self._mirrorFailed(e) |
| 1840 | |
| 1841 | - except InvalidURIError, e: |
| 1842 | + except InvalidURIError as e: |
| 1843 | self._mirrorFailed(e) |
| 1844 | |
| 1845 | except (KeyboardInterrupt, SystemExit): |
| 1846 | |
| 1847 | === modified file 'lib/lp/codehosting/safe_open.py' |
| 1848 | --- lib/lp/codehosting/safe_open.py 2012-01-06 11:08:30 +0000 |
| 1849 | +++ lib/lp/codehosting/safe_open.py 2012-07-03 08:07:22 +0000 |
| 1850 | @@ -317,7 +317,7 @@ |
| 1851 | prober = prober_kls() |
| 1852 | try: |
| 1853 | return transport, prober.probe_transport(transport) |
| 1854 | - except errors.NotBranchError, e: |
| 1855 | + except errors.NotBranchError as e: |
| 1856 | last_error = e |
| 1857 | else: |
| 1858 | raise last_error |
| 1859 | |
| 1860 | === modified file 'lib/lp/codehosting/scripts/modifiedbranches.py' |
| 1861 | --- lib/lp/codehosting/scripts/modifiedbranches.py 2012-01-01 02:58:52 +0000 |
| 1862 | +++ lib/lp/codehosting/scripts/modifiedbranches.py 2012-07-03 08:07:22 +0000 |
| 1863 | @@ -80,7 +80,7 @@ |
| 1864 | try: |
| 1865 | parsed_time = strptime(self.options.since, '%Y-%m-%d') |
| 1866 | last_modified = datetime(*(parsed_time[:3])) |
| 1867 | - except ValueError, e: |
| 1868 | + except ValueError as e: |
| 1869 | raise LaunchpadScriptFailure(str(e)) |
| 1870 | else: |
| 1871 | raise LaunchpadScriptFailure( |
| 1872 | |
| 1873 | === modified file 'lib/lp/codehosting/sftp.py' |
| 1874 | --- lib/lp/codehosting/sftp.py 2012-01-01 02:58:52 +0000 |
| 1875 | +++ lib/lp/codehosting/sftp.py 2012-07-03 08:07:22 +0000 |
| 1876 | @@ -68,7 +68,7 @@ |
| 1877 | osutils.check_legal_path(abspath) |
| 1878 | try: |
| 1879 | chunk_file = os.open(abspath, os.O_CREAT | os.O_WRONLY) |
| 1880 | - except OSError, e: |
| 1881 | + except OSError as e: |
| 1882 | if e.errno != errno.EISDIR: |
| 1883 | raise |
| 1884 | raise FileIsADirectory(name) |
| 1885 | |
| 1886 | === modified file 'lib/lp/codehosting/sshserver/session.py' |
| 1887 | --- lib/lp/codehosting/sshserver/session.py 2012-04-16 23:02:44 +0000 |
| 1888 | +++ lib/lp/codehosting/sshserver/session.py 2012-07-03 08:07:22 +0000 |
| 1889 | @@ -121,7 +121,7 @@ |
| 1890 | client_sock.sendall(message) |
| 1891 | # We define the requests to be no bigger than 1kB. (For now) |
| 1892 | response = client_sock.recv(1024) |
| 1893 | - except socket.error, e: |
| 1894 | + except socket.error as e: |
| 1895 | # TODO: What exceptions should be raised? |
| 1896 | # Raising the raw exception seems to kill the twisted reactor |
| 1897 | # Note that if the connection is refused, we *could* just |
| 1898 | @@ -346,7 +346,7 @@ |
| 1899 | """ |
| 1900 | try: |
| 1901 | executable, arguments = self.getCommandToRun(command) |
| 1902 | - except ForbiddenCommand, e: |
| 1903 | + except ForbiddenCommand as e: |
| 1904 | self.errorWithMessage(protocol, str(e) + '\r\n') |
| 1905 | return |
| 1906 | log.msg('Running: %r, %r' % (executable, arguments)) |
| 1907 | |
| 1908 | === modified file 'lib/lp/codehosting/vfs/transport.py' |
| 1909 | --- lib/lp/codehosting/vfs/transport.py 2011-07-18 20:46:27 +0000 |
| 1910 | +++ lib/lp/codehosting/vfs/transport.py 2012-07-03 08:07:22 +0000 |
| 1911 | @@ -135,7 +135,7 @@ |
| 1912 | method = getattr(transport, method_name) |
| 1913 | try: |
| 1914 | return method(path, *args, **kwargs) |
| 1915 | - except BaseException, e: |
| 1916 | + except BaseException as e: |
| 1917 | # It's much cheaper to explicitly construct a Failure than to |
| 1918 | # let Deferred build automatically, because the automatic one |
| 1919 | # will capture the traceback and perform an expensive |
| 1920 | |
| 1921 | === modified file 'lib/lp/hardwaredb/scripts/hwdbsubmissions.py' |
| 1922 | --- lib/lp/hardwaredb/scripts/hwdbsubmissions.py 2011-12-30 09:16:36 +0000 |
| 1923 | +++ lib/lp/hardwaredb/scripts/hwdbsubmissions.py 2012-07-03 08:07:22 +0000 |
| 1924 | @@ -219,7 +219,7 @@ |
| 1925 | submission = self.fixFrequentErrors(submission) |
| 1926 | try: |
| 1927 | tree = etree.parse(StringIO(submission), parser=self.doc_parser) |
| 1928 | - except SyntaxError, error_value: |
| 1929 | + except SyntaxError as error_value: |
| 1930 | self._logError(error_value, submission_key) |
| 1931 | return None |
| 1932 | |
| 1933 | @@ -988,7 +988,7 @@ |
| 1934 | if result is None: |
| 1935 | return None |
| 1936 | submission_data[node.tag] = result |
| 1937 | - except ValueError, value: |
| 1938 | + except ValueError as value: |
| 1939 | self._logError(value, self.submission_key) |
| 1940 | return None |
| 1941 | return submission_data |
| 1942 | @@ -1480,7 +1480,7 @@ |
| 1943 | udi_device_map = self.getUDIDeviceMap( |
| 1944 | parsed_data['hardware']['hal']['devices']) |
| 1945 | udi_children = self.getUDIChildren(udi_device_map) |
| 1946 | - except ValueError, value: |
| 1947 | + except ValueError as value: |
| 1948 | self._logError(value, self.submission_key) |
| 1949 | return False |
| 1950 | |
| 1951 | |
| 1952 | === modified file 'lib/lp/poppy/hooks.py' |
| 1953 | --- lib/lp/poppy/hooks.py 2011-02-23 14:51:30 +0000 |
| 1954 | +++ lib/lp/poppy/hooks.py 2012-07-03 08:07:22 +0000 |
| 1955 | @@ -158,7 +158,7 @@ |
| 1956 | # self.logger.debug("Accepting login for %s" % user) |
| 1957 | # self.clients[fsroot]["distro"] = user |
| 1958 | # return True |
| 1959 | - #except object, e: |
| 1960 | + #except object as e: |
| 1961 | # print e |
| 1962 | #return False |
| 1963 | |
| 1964 | |
| 1965 | === modified file 'lib/lp/poppy/twistedsftp.py' |
| 1966 | --- lib/lp/poppy/twistedsftp.py 2011-11-30 15:05:14 +0000 |
| 1967 | +++ lib/lp/poppy/twistedsftp.py 2012-07-03 08:07:22 +0000 |
| 1968 | @@ -129,7 +129,7 @@ |
| 1969 | try: |
| 1970 | chunk_file = os.open( |
| 1971 | self.filename, os.O_CREAT | os.O_WRONLY, 0644) |
| 1972 | - except OSError, e: |
| 1973 | + except OSError as e: |
| 1974 | if e.errno != errno.EISDIR: |
| 1975 | raise |
| 1976 | raise FileIsADirectory(self.filename) |
| 1977 | |
| 1978 | === modified file 'lib/lp/registry/browser/nameblacklist.py' |
| 1979 | --- lib/lp/registry/browser/nameblacklist.py 2012-01-05 20:11:40 +0000 |
| 1980 | +++ lib/lp/registry/browser/nameblacklist.py 2012-07-03 08:07:22 +0000 |
| 1981 | @@ -62,7 +62,7 @@ |
| 1982 | self.setFieldError( |
| 1983 | 'regexp', |
| 1984 | 'This regular expression already exists.') |
| 1985 | - except re.error, e: |
| 1986 | + except re.error as e: |
| 1987 | self.setFieldError( |
| 1988 | 'regexp', |
| 1989 | 'Invalid regular expression: %s' % e) |
| 1990 | |
| 1991 | === modified file 'lib/lp/registry/browser/person.py' |
| 1992 | --- lib/lp/registry/browser/person.py 2012-06-14 05:18:22 +0000 |
| 1993 | +++ lib/lp/registry/browser/person.py 2012-07-03 08:07:22 +0000 |
| 1994 | @@ -1462,7 +1462,7 @@ |
| 1995 | self.request.response.addInfoNotification( |
| 1996 | _("Voucher redeemed successfully")) |
| 1997 | self.removeRedeemableVoucher(voucher) |
| 1998 | - except SalesforceVoucherProxyException, error: |
| 1999 | + except SalesforceVoucherProxyException as error: |
| 2000 | self.addError( |
| 2001 | _("The voucher could not be redeemed at this time.")) |
| 2002 | # Log an OOPS report without raising an error. |
| 2003 | @@ -4326,7 +4326,7 @@ |
| 2004 | try: |
| 2005 | send_direct_contact_email( |
| 2006 | sender_email, self.recipients, subject, message) |
| 2007 | - except QuotaReachedError, error: |
| 2008 | + except QuotaReachedError as error: |
| 2009 | fmt_date = DateTimeFormatterAPI(self.next_try) |
| 2010 | self.request.response.addErrorNotification( |
| 2011 | _('Your message was not sent because you have exceeded your ' |
| 2012 | |
| 2013 | === modified file 'lib/lp/registry/browser/productseries.py' |
| 2014 | --- lib/lp/registry/browser/productseries.py 2012-07-02 06:42:52 +0000 |
| 2015 | +++ lib/lp/registry/browser/productseries.py 2012-07-03 08:07:22 +0000 |
| 2016 | @@ -1091,7 +1091,7 @@ |
| 2017 | url=url, |
| 2018 | cvs_root=cvs_root, |
| 2019 | cvs_module=cvs_module) |
| 2020 | - except BranchExists, e: |
| 2021 | + except BranchExists as e: |
| 2022 | self._setBranchExists(e.existing_branch, |
| 2023 | 'branch_name') |
| 2024 | self.errors_in_action = True |
| 2025 | @@ -1123,7 +1123,7 @@ |
| 2026 | self.addError( |
| 2027 | "You are not allowed to create branches in %s." % |
| 2028 | self.context.displayname) |
| 2029 | - except BranchExists, e: |
| 2030 | + except BranchExists as e: |
| 2031 | self._setBranchExists(e.existing_branch, 'branch_name') |
| 2032 | if branch is None: |
| 2033 | self.errors_in_action = True |
| 2034 | |
| 2035 | === modified file 'lib/lp/registry/browser/team.py' |
| 2036 | --- lib/lp/registry/browser/team.py 2012-06-26 04:18:31 +0000 |
| 2037 | +++ lib/lp/registry/browser/team.py 2012-07-03 08:07:22 +0000 |
| 2038 | @@ -355,7 +355,7 @@ |
| 2039 | self.context.transitionVisibility(visibility, self.user) |
| 2040 | del data['visibility'] |
| 2041 | self.updateContextFromData(data) |
| 2042 | - except ImmutableVisibilityError, error: |
| 2043 | + except ImmutableVisibilityError as error: |
| 2044 | self.request.response.addErrorNotification(str(error)) |
| 2045 | # Abort must be called or changes to fields before the one causing |
| 2046 | # the error will be committed. If we have a database validation |
| 2047 | @@ -513,7 +513,7 @@ |
| 2048 | if email is None or email.person != self.context: |
| 2049 | try: |
| 2050 | validate_new_team_email(data['contact_address']) |
| 2051 | - except LaunchpadValidationError, error: |
| 2052 | + except LaunchpadValidationError as error: |
| 2053 | # We need to wrap this in structured, so that the |
| 2054 | # markup is preserved. Note that this puts the |
| 2055 | # responsibility for security on the exception thrower. |
| 2056 | @@ -1729,7 +1729,7 @@ |
| 2057 | return (len(self.super_teams) > 0 |
| 2058 | or (self.context.open_membership_invitations |
| 2059 | and check_permission('launchpad.Edit', self.context))) |
| 2060 | - except AttributeError, e: |
| 2061 | + except AttributeError as e: |
| 2062 | raise AssertionError(e) |
| 2063 | |
| 2064 | @property |
| 2065 | |
| 2066 | === modified file 'lib/lp/registry/browser/teammembership.py' |
| 2067 | --- lib/lp/registry/browser/teammembership.py 2012-01-03 22:28:10 +0000 |
| 2068 | +++ lib/lp/registry/browser/teammembership.py 2012-07-03 08:07:22 +0000 |
| 2069 | @@ -278,7 +278,7 @@ |
| 2070 | else: |
| 2071 | try: |
| 2072 | expires = self._getExpirationDate() |
| 2073 | - except ValueError, err: |
| 2074 | + except ValueError as err: |
| 2075 | self.errormessage = ( |
| 2076 | 'Invalid expiration: %s' % err) |
| 2077 | return False |
| 2078 | @@ -304,7 +304,7 @@ |
| 2079 | expires = None |
| 2080 | try: |
| 2081 | expires = self.expiration_widget.getInputValue() |
| 2082 | - except InputErrors, value: |
| 2083 | + except InputErrors as value: |
| 2084 | # Handle conversion errors. We have to do this explicitly here |
| 2085 | # because we are not using the full form machinery which would |
| 2086 | # put the relevant error message into the field error. We are |
| 2087 | |
| 2088 | === modified file 'lib/lp/registry/interfaces/distroseries.py' |
| 2089 | --- lib/lp/registry/interfaces/distroseries.py 2012-07-02 15:52:14 +0000 |
| 2090 | +++ lib/lp/registry/interfaces/distroseries.py 2012-07-03 08:07:22 +0000 |
| 2091 | @@ -171,7 +171,7 @@ |
| 2092 | # have stricter version rules than the schema. The version must |
| 2093 | # be a debversion. |
| 2094 | Version(version) |
| 2095 | - except VersionError, error: |
| 2096 | + except VersionError as error: |
| 2097 | raise LaunchpadValidationError( |
| 2098 | "'%s': %s" % (version, error)) |
| 2099 | |
| 2100 | |
| 2101 | === modified file 'lib/lp/registry/model/codeofconduct.py' |
| 2102 | --- lib/lp/registry/model/codeofconduct.py 2012-01-06 11:08:30 +0000 |
| 2103 | +++ lib/lp/registry/model/codeofconduct.py 2012-07-03 08:07:22 +0000 |
| 2104 | @@ -268,7 +268,7 @@ |
| 2105 | |
| 2106 | try: |
| 2107 | sig = gpghandler.getVerifiedSignature(sane_signedcode) |
| 2108 | - except GPGVerificationError, e: |
| 2109 | + except GPGVerificationError as e: |
| 2110 | return str(e) |
| 2111 | |
| 2112 | if not sig.fingerprint: |
| 2113 | |
| 2114 | === modified file 'lib/lp/registry/model/distroseries.py' |
| 2115 | --- lib/lp/registry/model/distroseries.py 2012-06-19 03:26:57 +0000 |
| 2116 | +++ lib/lp/registry/model/distroseries.py 2012-07-03 08:07:22 +0000 |
| 2117 | @@ -1632,7 +1632,7 @@ |
| 2118 | rebuild, overlays, overlay_pockets, overlay_components) |
| 2119 | try: |
| 2120 | initialize_series.check() |
| 2121 | - except InitializationError, e: |
| 2122 | + except InitializationError as e: |
| 2123 | raise DerivationError(e) |
| 2124 | getUtility(IInitializeDistroSeriesJobSource).create( |
| 2125 | self, parents, architectures, archindep_archtag, packagesets, |
| 2126 | |
| 2127 | === modified file 'lib/lp/registry/scripts/distributionmirror_prober.py' |
| 2128 | --- lib/lp/registry/scripts/distributionmirror_prober.py 2012-01-01 02:58:52 +0000 |
| 2129 | +++ lib/lp/registry/scripts/distributionmirror_prober.py 2012-07-03 08:07:22 +0000 |
| 2130 | @@ -335,11 +335,11 @@ |
| 2131 | # XXX Guilherme Salgado 2007-04-23 bug=109223: |
| 2132 | # We can't assume url to be absolute here. |
| 2133 | self.setURL(url) |
| 2134 | - except (UnknownURLScheme,), e: |
| 2135 | + except UnknownURLScheme as e: |
| 2136 | # Since we've got the UnknownURLScheme after a redirect, we need |
| 2137 | # to raise it in a form that can be ignored in the layer above. |
| 2138 | self.failed(UnknownURLSchemeAfterRedirect(url)) |
| 2139 | - except (InfiniteLoopDetected,), e: |
| 2140 | + except InfiniteLoopDetected as e: |
| 2141 | self.failed(e) |
| 2142 | |
| 2143 | else: |
| 2144 | @@ -619,7 +619,7 @@ |
| 2145 | url = config.distributionmirrorprober.cdimage_file_list_url |
| 2146 | try: |
| 2147 | return urllib2.urlopen(_build_request_for_cdimage_file_list(url)) |
| 2148 | - except urllib2.URLError, e: |
| 2149 | + except urllib2.URLError as e: |
| 2150 | raise UnableToFetchCDImageFileList( |
| 2151 | 'Unable to fetch %s: %s' % (url, e)) |
| 2152 | |
| 2153 | @@ -715,7 +715,7 @@ |
| 2154 | mirror.deleteAllMirrorCDImageSeries() |
| 2155 | try: |
| 2156 | cdimage_paths = get_expected_cdimage_paths() |
| 2157 | - except UnableToFetchCDImageFileList, e: |
| 2158 | + except UnableToFetchCDImageFileList as e: |
| 2159 | logger.error(e) |
| 2160 | return |
| 2161 | |
| 2162 | |
| 2163 | === modified file 'lib/lp/registry/scripts/mlistimport.py' |
| 2164 | --- lib/lp/registry/scripts/mlistimport.py 2012-06-13 21:14:17 +0000 |
| 2165 | +++ lib/lp/registry/scripts/mlistimport.py 2012-07-03 08:07:22 +0000 |
| 2166 | @@ -85,7 +85,7 @@ |
| 2167 | may_subscribe_to_list=False) |
| 2168 | try: |
| 2169 | self.mailing_list.subscribe(person, email) |
| 2170 | - except CannotSubscribe, error: |
| 2171 | + except CannotSubscribe as error: |
| 2172 | self.log.error('%s', error) |
| 2173 | # It's okay to str()-ify these because addresses and person names |
| 2174 | # are guaranteed to be in the ASCII range. |
| 2175 | |
| 2176 | === modified file 'lib/lp/registry/scripts/productreleasefinder/walker.py' |
| 2177 | --- lib/lp/registry/scripts/productreleasefinder/walker.py 2012-04-16 23:02:44 +0000 |
| 2178 | +++ lib/lp/registry/scripts/productreleasefinder/walker.py 2012-07-03 08:07:22 +0000 |
| 2179 | @@ -125,7 +125,7 @@ |
| 2180 | """ |
| 2181 | try: |
| 2182 | self.open() |
| 2183 | - except (IOError, socket.error), e: |
| 2184 | + except (IOError, socket.error) as e: |
| 2185 | self.log.info("Could not connect to %s" % self.base) |
| 2186 | self.log.info("Failure: %s" % e) |
| 2187 | return |
| 2188 | @@ -341,10 +341,10 @@ |
| 2189 | try: |
| 2190 | self.request("HEAD", path) |
| 2191 | return False |
| 2192 | - except urllib2.HTTPError, exc: |
| 2193 | + except urllib2.HTTPError as exc: |
| 2194 | if exc.code != 301: |
| 2195 | return False |
| 2196 | - except (IOError, socket.error), exc: |
| 2197 | + except (IOError, socket.error) as exc: |
| 2198 | # Raise HTTPWalkerError for other IO or socket errors. |
| 2199 | raise HTTPWalkerError(str(exc)) |
| 2200 | |
| 2201 | @@ -376,7 +376,7 @@ |
| 2202 | soup = BeautifulSoup(response.read()) |
| 2203 | finally: |
| 2204 | response.close() |
| 2205 | - except (IOError, socket.error), exc: |
| 2206 | + except (IOError, socket.error) as exc: |
| 2207 | raise HTTPWalkerError(str(exc)) |
| 2208 | |
| 2209 | base = URI(self.base).resolve(dirname) |
| 2210 | |
| 2211 | === modified file 'lib/lp/registry/tests/test_distributionmirror_prober.py' |
| 2212 | --- lib/lp/registry/tests/test_distributionmirror_prober.py 2012-04-17 17:02:23 +0000 |
| 2213 | +++ lib/lp/registry/tests/test_distributionmirror_prober.py 2012-07-03 08:07:22 +0000 |
| 2214 | @@ -751,17 +751,17 @@ |
| 2215 | try: |
| 2216 | callbacks.deleteMirrorSeries( |
| 2217 | Failure(ProberTimeout('http://localhost/', 5))) |
| 2218 | - except Exception, e: |
| 2219 | + except Exception as e: |
| 2220 | self.fail("A timeout shouldn't be propagated. Got %s" % e) |
| 2221 | try: |
| 2222 | callbacks.deleteMirrorSeries( |
| 2223 | Failure(BadResponseCode(str(httplib.INTERNAL_SERVER_ERROR)))) |
| 2224 | - except Exception, e: |
| 2225 | + except Exception as e: |
| 2226 | self.fail( |
| 2227 | "A bad response code shouldn't be propagated. Got %s" % e) |
| 2228 | try: |
| 2229 | callbacks.deleteMirrorSeries(Failure(ConnectionSkipped())) |
| 2230 | - except Exception, e: |
| 2231 | + except Exception as e: |
| 2232 | self.fail("A ConnectionSkipped exception shouldn't be " |
| 2233 | "propagated. Got %s" % e) |
| 2234 | |
| 2235 | |
| 2236 | === modified file 'lib/lp/registry/tests/test_mlists.py' |
| 2237 | --- lib/lp/registry/tests/test_mlists.py 2012-01-04 06:52:11 +0000 |
| 2238 | +++ lib/lp/registry/tests/test_mlists.py 2012-07-03 08:07:22 +0000 |
| 2239 | @@ -63,7 +63,7 @@ |
| 2240 | def tearDown(self): |
| 2241 | try: |
| 2242 | os.remove(self.filename) |
| 2243 | - except OSError, error: |
| 2244 | + except OSError as error: |
| 2245 | if error.errno != errno.ENOENT: |
| 2246 | raise |
| 2247 | |
| 2248 | |
| 2249 | === modified file 'lib/lp/registry/tests/test_packaging.py' |
| 2250 | --- lib/lp/registry/tests/test_packaging.py 2012-01-01 02:58:52 +0000 |
| 2251 | +++ lib/lp/registry/tests/test_packaging.py 2012-07-03 08:07:22 +0000 |
| 2252 | @@ -273,7 +273,7 @@ |
| 2253 | productseries=firefox_trunk, |
| 2254 | sourcepackagename=firefox_name, |
| 2255 | distroseries=ubuntu_hoary) |
| 2256 | - except AssertionError, exception: |
| 2257 | + except AssertionError as exception: |
| 2258 | self.assertEqual( |
| 2259 | str(exception), |
| 2260 | "Tried to delete non-existent Packaging: " |
| 2261 | |
| 2262 | === modified file 'lib/lp/registry/tests/test_person.py' |
| 2263 | --- lib/lp/registry/tests/test_person.py 2012-05-14 11:19:45 +0000 |
| 2264 | +++ lib/lp/registry/tests/test_person.py 2012-07-03 08:07:22 +0000 |
| 2265 | @@ -706,7 +706,7 @@ |
| 2266 | self.otherteam.visibility = PersonVisibility.PRIVATE |
| 2267 | try: |
| 2268 | self.otherteam.visibility = PersonVisibility.PUBLIC |
| 2269 | - except ImmutableVisibilityError, exc: |
| 2270 | + except ImmutableVisibilityError as exc: |
| 2271 | self.assertEqual( |
| 2272 | str(exc), |
| 2273 | 'A private team cannot change visibility.') |
| 2274 | |
| 2275 | === modified file 'lib/lp/registry/tests/test_project_milestone.py' |
| 2276 | --- lib/lp/registry/tests/test_project_milestone.py 2012-01-01 02:58:52 +0000 |
| 2277 | +++ lib/lp/registry/tests/test_project_milestone.py 2012-07-03 08:07:22 +0000 |
| 2278 | @@ -330,7 +330,7 @@ |
| 2279 | milestone.createProductRelease, 1, now) |
| 2280 | try: |
| 2281 | milestone.createProductRelease(1, now) |
| 2282 | - except MultipleProductReleases, e: |
| 2283 | + except MultipleProductReleases as e: |
| 2284 | self.assert_( |
| 2285 | str(e), 'A milestone can only have one ProductRelease.') |
| 2286 | |
| 2287 | |
| 2288 | === modified file 'lib/lp/registry/tests/test_xmlrpc.py' |
| 2289 | --- lib/lp/registry/tests/test_xmlrpc.py 2012-02-14 09:28:26 +0000 |
| 2290 | +++ lib/lp/registry/tests/test_xmlrpc.py 2012-07-03 08:07:22 +0000 |
| 2291 | @@ -100,7 +100,7 @@ |
| 2292 | try: |
| 2293 | self.rpc_proxy.getOrCreateSoftwareCenterCustomer( |
| 2294 | openid_identifier, 'a@b.com', 'Joe Blogs') |
| 2295 | - except xmlrpclib.Fault, e: |
| 2296 | + except xmlrpclib.Fault as e: |
| 2297 | fault_raised = True |
| 2298 | self.assertEqual(370, e.faultCode) |
| 2299 | self.assertIn(openid_identifier, e.faultString) |
| 2300 | @@ -116,7 +116,7 @@ |
| 2301 | try: |
| 2302 | self.rpc_proxy.getOrCreateSoftwareCenterCustomer( |
| 2303 | 'foo', 'a@b.com', 'Joe Blogs') |
| 2304 | - except xmlrpclib.Fault, e: |
| 2305 | + except xmlrpclib.Fault as e: |
| 2306 | fault_raised = True |
| 2307 | self.assertEqual(400, e.faultCode) |
| 2308 | self.assertIn('a@b.com', e.faultString) |
| 2309 | |
| 2310 | === modified file 'lib/lp/scripts/garbo.py' |
| 2311 | --- lib/lp/scripts/garbo.py 2012-07-02 08:26:24 +0000 |
| 2312 | +++ lib/lp/scripts/garbo.py 2012-07-03 08:07:22 +0000 |
| 2313 | @@ -1084,7 +1084,7 @@ |
| 2314 | for spec in self.getNextBatch(chunk_size): |
| 2315 | try: |
| 2316 | work_items = extractWorkItemsFromWhiteboard(spec) |
| 2317 | - except Exception, e: |
| 2318 | + except Exception as e: |
| 2319 | self.log.info( |
| 2320 | "Failed to parse whiteboard of %s: %s" % ( |
| 2321 | spec, unicode(e))) |
| 2322 | |
| 2323 | === modified file 'lib/lp/scripts/runlaunchpad.py' |
| 2324 | --- lib/lp/scripts/runlaunchpad.py 2012-01-13 14:20:49 +0000 |
| 2325 | +++ lib/lp/scripts/runlaunchpad.py 2012-07-03 08:07:22 +0000 |
| 2326 | @@ -449,7 +449,7 @@ |
| 2327 | signal.pause() |
| 2328 | except KeyboardInterrupt: |
| 2329 | pass |
| 2330 | - except Exception, e: |
| 2331 | + except Exception as e: |
| 2332 | print >> sys.stderr, "stopping services on exception %r" % e |
| 2333 | for service in services: |
| 2334 | print >> sys.stderr, service, "fixture details:" |
| 2335 | |
| 2336 | === modified file 'lib/lp/scripts/utilities/killservice.py' |
| 2337 | --- lib/lp/scripts/utilities/killservice.py 2012-04-16 23:02:44 +0000 |
| 2338 | +++ lib/lp/scripts/utilities/killservice.py 2012-07-03 08:07:22 +0000 |
| 2339 | @@ -54,7 +54,7 @@ |
| 2340 | log.debug("PID file is %s", pidfile_path(service)) |
| 2341 | try: |
| 2342 | pid = get_pid(service) |
| 2343 | - except ValueError, error: |
| 2344 | + except ValueError as error: |
| 2345 | log.error(error) |
| 2346 | continue |
| 2347 | if pid is not None: |
| 2348 | @@ -62,7 +62,7 @@ |
| 2349 | try: |
| 2350 | os.kill(pid, SIGTERM) |
| 2351 | pids.append((service, pid)) |
| 2352 | - except OSError, x: |
| 2353 | + except OSError as x: |
| 2354 | log.error( |
| 2355 | "Unable to SIGTERM %s (%d) - %s", |
| 2356 | service, pid, x.strerror) |
| 2357 | @@ -79,7 +79,7 @@ |
| 2358 | "SIGTERM failed to kill %s (%d). Trying SIGKILL", service, pid) |
| 2359 | try: |
| 2360 | os.kill(pid, SIGKILL) |
| 2361 | - except OSError, x: |
| 2362 | + except OSError as x: |
| 2363 | log.error( |
| 2364 | "Unable to SIGKILL %s (%d) - %s", service, pid, x.strerror) |
| 2365 | |
| 2366 | @@ -106,7 +106,7 @@ |
| 2367 | """True if the given process exists.""" |
| 2368 | try: |
| 2369 | os.getpgid(pid) |
| 2370 | - except OSError, x: |
| 2371 | + except OSError as x: |
| 2372 | if x.errno == 3: |
| 2373 | return False |
| 2374 | logging.error("Unknown exception from getpgid - %s", str(x)) |
| 2375 | |
| 2376 | === modified file 'lib/lp/scripts/utilities/pageperformancereport.py' |
| 2377 | --- lib/lp/scripts/utilities/pageperformancereport.py 2012-03-14 04:41:36 +0000 |
| 2378 | +++ lib/lp/scripts/utilities/pageperformancereport.py 2012-07-03 08:07:22 +0000 |
| 2379 | @@ -730,7 +730,7 @@ |
| 2380 | regexp = script_config.get('categories', option) |
| 2381 | try: |
| 2382 | categories.append(Category(option, regexp)) |
| 2383 | - except sre_constants.error, x: |
| 2384 | + except sre_constants.error as x: |
| 2385 | log.fatal("Unable to compile regexp %r (%s)" % (regexp, x)) |
| 2386 | return 1 |
| 2387 | categories.sort() |
| 2388 | @@ -971,7 +971,7 @@ |
| 2389 | times.add_request(request) |
| 2390 | else: |
| 2391 | raise MalformedLine('Unknown record type %s', record_type) |
| 2392 | - except MalformedLine, x: |
| 2393 | + except MalformedLine as x: |
| 2394 | log.error( |
| 2395 | "Malformed line %s (%s)" % (repr(line), x)) |
| 2396 | |
| 2397 | |
| 2398 | === modified file 'lib/lp/services/apachelogparser/base.py' |
| 2399 | --- lib/lp/services/apachelogparser/base.py 2012-01-01 02:58:52 +0000 |
| 2400 | +++ lib/lp/services/apachelogparser/base.py 2012-07-03 08:07:22 +0000 |
| 2401 | @@ -160,7 +160,7 @@ |
| 2402 | daily_downloads[country_code] += 1 |
| 2403 | except (KeyboardInterrupt, SystemExit): |
| 2404 | raise |
| 2405 | - except Exception, e: |
| 2406 | + except Exception as e: |
| 2407 | # Update parsed_bytes to the end of the last line we parsed |
| 2408 | # successfully, log this as an error and break the loop so that |
| 2409 | # we return. |
| 2410 | |
| 2411 | === modified file 'lib/lp/services/command_spawner.py' |
| 2412 | --- lib/lp/services/command_spawner.py 2011-12-19 23:38:16 +0000 |
| 2413 | +++ lib/lp/services/command_spawner.py 2012-07-03 08:07:22 +0000 |
| 2414 | @@ -171,7 +171,7 @@ |
| 2415 | """Read output from `pipe_file`.""" |
| 2416 | try: |
| 2417 | output = pipe_file.read() |
| 2418 | - except IOError, e: |
| 2419 | + except IOError as e: |
| 2420 | # "Resource temporarily unavailable"--not an error really, |
| 2421 | # just means there's nothing to read. |
| 2422 | if e.errno != errno.EAGAIN: |
| 2423 | |
| 2424 | === modified file 'lib/lp/services/config/__init__.py' |
| 2425 | --- lib/lp/services/config/__init__.py 2012-02-24 16:51:25 +0000 |
| 2426 | +++ lib/lp/services/config/__init__.py 2012-07-03 08:07:22 +0000 |
| 2427 | @@ -215,7 +215,7 @@ |
| 2428 | self._config = schema.load(config_file) |
| 2429 | try: |
| 2430 | self._config.validate() |
| 2431 | - except ConfigErrors, error: |
| 2432 | + except ConfigErrors as error: |
| 2433 | message = '\n'.join([str(e) for e in error.errors]) |
| 2434 | raise ConfigErrors(message) |
| 2435 | self._setZConfig() |
| 2436 | |
| 2437 | === modified file 'lib/lp/services/config/tests/test_config.py' |
| 2438 | --- lib/lp/services/config/tests/test_config.py 2012-05-03 16:21:22 +0000 |
| 2439 | +++ lib/lp/services/config/tests/test_config.py 2012-07-03 08:07:22 +0000 |
| 2440 | @@ -62,7 +62,7 @@ |
| 2441 | config = schema.load(config_file) |
| 2442 | try: |
| 2443 | config.validate() |
| 2444 | - except ConfigErrors, error: |
| 2445 | + except ConfigErrors as error: |
| 2446 | message = '\n'.join([str(e) for e in error.errors]) |
| 2447 | self.fail(message) |
| 2448 | # Hack the config file name into the class name. |
| 2449 | |
| 2450 | === modified file 'lib/lp/services/doc/pidfile.txt' |
| 2451 | --- lib/lp/services/doc/pidfile.txt 2011-12-30 08:13:14 +0000 |
| 2452 | +++ lib/lp/services/doc/pidfile.txt 2012-07-03 08:07:22 +0000 |
| 2453 | @@ -105,7 +105,7 @@ |
| 2454 | ... try: |
| 2455 | ... # Is it still here at all? |
| 2456 | ... os.kill(pid, 0) |
| 2457 | - ... except OSError, e: |
| 2458 | + ... except OSError as e: |
| 2459 | ... if e.errno == errno.ESRCH: |
| 2460 | ... print 'Error: pid file was not removed' |
| 2461 | ... else: raise |
| 2462 | |
| 2463 | === modified file 'lib/lp/services/features/browser/edit.py' |
| 2464 | --- lib/lp/services/features/browser/edit.py 2012-01-01 02:58:52 +0000 |
| 2465 | +++ lib/lp/services/features/browser/edit.py 2012-07-03 08:07:22 +0000 |
| 2466 | @@ -114,5 +114,6 @@ |
| 2467 | # Unfortunately if the field is '', zope leaves it out of data. |
| 2468 | self.request.features.rule_source.parseRules( |
| 2469 | data.get('feature_rules') or '') |
| 2470 | - except (IndexError, TypeError, ValueError, DuplicatePriorityError), e: |
| 2471 | + except (IndexError, TypeError, ValueError, |
| 2472 | + DuplicatePriorityError) as e: |
| 2473 | self.setFieldError('feature_rules', 'Invalid rule syntax: %s' % e) |
| 2474 | |
| 2475 | === modified file 'lib/lp/services/fields/__init__.py' |
| 2476 | --- lib/lp/services/fields/__init__.py 2012-06-02 11:53:05 +0000 |
| 2477 | +++ lib/lp/services/fields/__init__.py 2012-07-03 08:07:22 +0000 |
| 2478 | @@ -625,7 +625,7 @@ |
| 2479 | input = input.strip() |
| 2480 | try: |
| 2481 | uri = URI(input) |
| 2482 | - except InvalidURIError, exc: |
| 2483 | + except InvalidURIError as exc: |
| 2484 | raise LaunchpadValidationError(str(exc)) |
| 2485 | # If there is a policy for whether trailing slashes are |
| 2486 | # allowed at the end of the path segment, ensure that the |
| 2487 | |
| 2488 | === modified file 'lib/lp/services/googlesearch/__init__.py' |
| 2489 | --- lib/lp/services/googlesearch/__init__.py 2011-12-30 08:13:14 +0000 |
| 2490 | +++ lib/lp/services/googlesearch/__init__.py 2012-07-03 08:07:22 +0000 |
| 2491 | @@ -211,7 +211,7 @@ |
| 2492 | action = timeline.start("google-search-api", search_url) |
| 2493 | try: |
| 2494 | gsp_xml = urlfetch(search_url) |
| 2495 | - except (TimeoutError, urllib2.HTTPError, urllib2.URLError), error: |
| 2496 | + except (TimeoutError, urllib2.HTTPError, urllib2.URLError) as error: |
| 2497 | # Google search service errors are not code errors. Let the |
| 2498 | # call site choose to handle the unavailable service. |
| 2499 | raise GoogleResponseError( |
| 2500 | |
| 2501 | === modified file 'lib/lp/services/googlesearch/googletestservice.py' |
| 2502 | --- lib/lp/services/googlesearch/googletestservice.py 2011-12-30 08:13:14 +0000 |
| 2503 | +++ lib/lp/services/googlesearch/googletestservice.py 2012-07-03 08:07:22 +0000 |
| 2504 | @@ -132,7 +132,7 @@ |
| 2505 | while True: |
| 2506 | try: |
| 2507 | sock.connect((host, port)) |
| 2508 | - except socket.error, err: |
| 2509 | + except socket.error as err: |
| 2510 | if err.args[0] in [errno.ECONNREFUSED, errno.ECONNABORTED]: |
| 2511 | elapsed = (time.time() - start) |
| 2512 | if elapsed > timeout: |
| 2513 | @@ -166,7 +166,7 @@ |
| 2514 | try: |
| 2515 | sock.connect((host, port)) |
| 2516 | sock.close() |
| 2517 | - except socket.error, err: |
| 2518 | + except socket.error as err: |
| 2519 | if err.args[0] == errno.ECONNREFUSED: |
| 2520 | # Success! The socket is closed. |
| 2521 | return |
| 2522 | @@ -231,7 +231,7 @@ |
| 2523 | # between freeing the socket in the killed process, and |
| 2524 | # opening it in the current one. |
| 2525 | wait_for_service_shutdown() |
| 2526 | - except os.error, err: |
| 2527 | + except os.error as err: |
| 2528 | if err.errno == errno.ESRCH: |
| 2529 | # Whoops, we got a 'No such process' error. The PID file |
| 2530 | # is probably stale, so we'll remove it to prevent trash |
| 2531 | @@ -246,7 +246,7 @@ |
| 2532 | """Unlink a file, but don't raise an error if the file is missing.""" |
| 2533 | try: |
| 2534 | os.unlink(filepath) |
| 2535 | - except os.error, err: |
| 2536 | + except os.error as err: |
| 2537 | if err.errno != errno.ENOENT: |
| 2538 | raise |
| 2539 | |
| 2540 | |
| 2541 | === modified file 'lib/lp/services/googlesearch/tests/googleserviceharness.py' |
| 2542 | --- lib/lp/services/googlesearch/tests/googleserviceharness.py 2011-12-29 05:29:36 +0000 |
| 2543 | +++ lib/lp/services/googlesearch/tests/googleserviceharness.py 2012-07-03 08:07:22 +0000 |
| 2544 | @@ -97,7 +97,7 @@ |
| 2545 | if cls.service: |
| 2546 | try: |
| 2547 | os.kill(cls.service.pid, signal.SIGTERM) |
| 2548 | - except OSError, error: |
| 2549 | + except OSError as error: |
| 2550 | if error.errno != errno.ESRCH: |
| 2551 | raise |
| 2552 | # The process with the given pid doesn't exist, so there's |
| 2553 | |
| 2554 | === modified file 'lib/lp/services/googlesearch/tests/test_googleservice.py' |
| 2555 | --- lib/lp/services/googlesearch/tests/test_googleservice.py 2011-12-30 08:13:14 +0000 |
| 2556 | +++ lib/lp/services/googlesearch/tests/test_googleservice.py 2012-07-03 08:07:22 +0000 |
| 2557 | @@ -41,7 +41,7 @@ |
| 2558 | """Return True if the specified process already exists.""" |
| 2559 | try: |
| 2560 | os.kill(pid, 0) |
| 2561 | - except os.error, err: |
| 2562 | + except os.error as err: |
| 2563 | if err.errno == errno.ESRCH: |
| 2564 | # All is well - the process doesn't exist. |
| 2565 | return False |
| 2566 | |
| 2567 | === modified file 'lib/lp/services/gpg/doc/gpg-signatures.txt' |
| 2568 | --- lib/lp/services/gpg/doc/gpg-signatures.txt 2011-12-24 17:49:30 +0000 |
| 2569 | +++ lib/lp/services/gpg/doc/gpg-signatures.txt 2012-07-03 08:07:22 +0000 |
| 2570 | @@ -217,7 +217,7 @@ |
| 2571 | ... """ |
| 2572 | >>> try: |
| 2573 | ... gpghandler.getVerifiedSignature(content) |
| 2574 | - ... except GPGVerificationError, e: |
| 2575 | + ... except GPGVerificationError as e: |
| 2576 | ... print e.args |
| 2577 | ... print e.code |
| 2578 | ... print e.signatures |
| 2579 | |
| 2580 | === modified file 'lib/lp/services/gpg/handler.py' |
| 2581 | --- lib/lp/services/gpg/handler.py 2012-06-29 14:36:44 +0000 |
| 2582 | +++ lib/lp/services/gpg/handler.py 2012-07-03 08:07:22 +0000 |
| 2583 | @@ -143,7 +143,7 @@ |
| 2584 | for i in range(3): |
| 2585 | try: |
| 2586 | signature = self.getVerifiedSignature(content, signature) |
| 2587 | - except GPGVerificationError, info: |
| 2588 | + except GPGVerificationError as info: |
| 2589 | errors.append(info) |
| 2590 | else: |
| 2591 | return signature |
| 2592 | @@ -186,7 +186,7 @@ |
| 2593 | # process it |
| 2594 | try: |
| 2595 | signatures = ctx.verify(*args) |
| 2596 | - except gpgme.GpgmeError, e: |
| 2597 | + except gpgme.GpgmeError as e: |
| 2598 | error = GPGVerificationError(e.strerror) |
| 2599 | for attr in ("args", "code", "signatures", "source"): |
| 2600 | if hasattr(e, attr): |
| 2601 | @@ -446,7 +446,7 @@ |
| 2602 | |
| 2603 | try: |
| 2604 | conn.request("POST", "/pks/add", params, headers) |
| 2605 | - except socket.error, err: |
| 2606 | + except socket.error as err: |
| 2607 | raise GPGUploadFailure( |
| 2608 | 'Could not reach keyserver at http://%s %s' % ( |
| 2609 | keyserver_http_url, str(err))) |
| 2610 | @@ -488,7 +488,7 @@ |
| 2611 | # minutes." The details of the error do not matter for users |
| 2612 | # (and for the code in callsites), but we should be able to see |
| 2613 | # if this problem occurs too often. |
| 2614 | - except urllib2.HTTPError, exc: |
| 2615 | + except urllib2.HTTPError as exc: |
| 2616 | # The key server behaves a bit odd when queried for non |
| 2617 | # existent keys: Instead of responding with a 404, it |
| 2618 | # returns a 500 error. But we can extract the fact that |
| 2619 | @@ -500,7 +500,7 @@ |
| 2620 | raise GPGKeyDoesNotExistOnServer(fingerprint) |
| 2621 | errorlog.globalErrorUtility.raising(sys.exc_info(), request) |
| 2622 | raise GPGKeyTemporarilyNotFoundError(fingerprint) |
| 2623 | - except (TimeoutError, urllib2.URLError), exc: |
| 2624 | + except (TimeoutError, urllib2.URLError) as exc: |
| 2625 | errorlog.globalErrorUtility.raising(sys.exc_info(), request) |
| 2626 | raise GPGKeyTemporarilyNotFoundError(fingerprint) |
| 2627 | finally: |
| 2628 | |
| 2629 | === modified file 'lib/lp/services/job/celeryconfig.py' |
| 2630 | --- lib/lp/services/job/celeryconfig.py 2012-06-14 05:18:22 +0000 |
| 2631 | +++ lib/lp/services/job/celeryconfig.py 2012-07-03 08:07:22 +0000 |
| 2632 | @@ -100,6 +100,6 @@ |
| 2633 | |
| 2634 | try: |
| 2635 | globals().update(configure(getattr(sys, 'argv', ['']))) |
| 2636 | -except ConfigurationError, error: |
| 2637 | +except ConfigurationError as error: |
| 2638 | print >>sys.stderr, error |
| 2639 | sys.exit(1) |
| 2640 | |
| 2641 | === modified file 'lib/lp/services/librarian/client.py' |
| 2642 | --- lib/lp/services/librarian/client.py 2012-06-29 14:36:44 +0000 |
| 2643 | +++ lib/lp/services/librarian/client.py 2012-07-03 08:07:22 +0000 |
| 2644 | @@ -94,7 +94,7 @@ |
| 2645 | self.state.s = socket.socket(AF_INET, SOCK_STREAM) |
| 2646 | self.state.s.connect((self.upload_host, self.upload_port)) |
| 2647 | self.state.f = self.state.s.makefile('w+', 0) |
| 2648 | - except socket.error, x: |
| 2649 | + except socket.error as x: |
| 2650 | raise UploadFailed( |
| 2651 | '[%s:%s]: %s' % (self.upload_host, self.upload_port, x)) |
| 2652 | |
| 2653 | @@ -482,7 +482,7 @@ |
| 2654 | while 1: |
| 2655 | try: |
| 2656 | return _File(urllib2.urlopen(url), url) |
| 2657 | - except urllib2.URLError, error: |
| 2658 | + except urllib2.URLError as error: |
| 2659 | # 404 errors indicate a data inconsistency: more than one |
| 2660 | # attempt to open the file is pointless. |
| 2661 | # |
| 2662 | |
| 2663 | === modified file 'lib/lp/services/librarian/tests/test_client.py' |
| 2664 | --- lib/lp/services/librarian/tests/test_client.py 2011-12-30 06:14:56 +0000 |
| 2665 | +++ lib/lp/services/librarian/tests/test_client.py 2012-07-03 08:07:22 +0000 |
| 2666 | @@ -104,7 +104,7 @@ |
| 2667 | client._getDatabaseName = lambda cur: 'wrong_database' |
| 2668 | try: |
| 2669 | client.addFile('sample.txt', 6, StringIO('sample'), 'text/plain') |
| 2670 | - except UploadFailed, e: |
| 2671 | + except UploadFailed as e: |
| 2672 | msg = e.args[0] |
| 2673 | self.failUnless( |
| 2674 | msg.startswith('Server said: 400 Wrong database'), |
| 2675 | |
| 2676 | === modified file 'lib/lp/services/librarianserver/librariangc.py' |
| 2677 | --- lib/lp/services/librarianserver/librariangc.py 2012-01-06 11:08:30 +0000 |
| 2678 | +++ lib/lp/services/librarianserver/librariangc.py 2012-07-03 08:07:22 +0000 |
| 2679 | @@ -486,7 +486,7 @@ |
| 2680 | path = get_file_path(content_id) |
| 2681 | try: |
| 2682 | os.unlink(path) |
| 2683 | - except OSError, e: |
| 2684 | + except OSError as e: |
| 2685 | if e.errno != errno.ENOENT: |
| 2686 | raise |
| 2687 | if config.librarian_server.upstream_host is None: |
| 2688 | |
| 2689 | === modified file 'lib/lp/services/librarianserver/libraryprotocol.py' |
| 2690 | --- lib/lp/services/librarianserver/libraryprotocol.py 2011-12-30 01:48:17 +0000 |
| 2691 | +++ lib/lp/services/librarianserver/libraryprotocol.py 2012-07-03 08:07:22 +0000 |
| 2692 | @@ -68,7 +68,7 @@ |
| 2693 | def lineReceived(self, line): |
| 2694 | try: |
| 2695 | getattr(self, 'line_' + self.state, self.badLine)(line) |
| 2696 | - except ProtocolViolation, e: |
| 2697 | + except ProtocolViolation as e: |
| 2698 | self.sendError(e.msg) |
| 2699 | except: |
| 2700 | self.unknownError() |
| 2701 | |
| 2702 | === modified file 'lib/lp/services/librarianserver/storage.py' |
| 2703 | --- lib/lp/services/librarianserver/storage.py 2011-12-30 06:14:56 +0000 |
| 2704 | +++ lib/lp/services/librarianserver/storage.py 2012-07-03 08:07:22 +0000 |
| 2705 | @@ -65,7 +65,7 @@ |
| 2706 | self.incoming = os.path.join(self.directory, 'incoming') |
| 2707 | try: |
| 2708 | os.mkdir(self.incoming) |
| 2709 | - except OSError, e: |
| 2710 | + except OSError as e: |
| 2711 | if e.errno != errno.EEXIST: |
| 2712 | raise |
| 2713 | |
| 2714 | @@ -191,7 +191,7 @@ |
| 2715 | raise DuplicateFileIDError(fileID) |
| 2716 | try: |
| 2717 | os.makedirs(os.path.dirname(location)) |
| 2718 | - except OSError, e: |
| 2719 | + except OSError as e: |
| 2720 | # If the directory already exists, that's ok. |
| 2721 | if e.errno != errno.EEXIST: |
| 2722 | raise |
| 2723 | |
| 2724 | === modified file 'lib/lp/services/librarianserver/tests/test_db_outage.py' |
| 2725 | --- lib/lp/services/librarianserver/tests/test_db_outage.py 2011-12-30 01:48:17 +0000 |
| 2726 | +++ lib/lp/services/librarianserver/tests/test_db_outage.py 2012-07-03 08:07:22 +0000 |
| 2727 | @@ -89,7 +89,7 @@ |
| 2728 | try: |
| 2729 | urllib2.urlopen(self.url).read() |
| 2730 | codes.add(200) |
| 2731 | - except urllib2.HTTPError, error: |
| 2732 | + except urllib2.HTTPError as error: |
| 2733 | codes.add(error.code) |
| 2734 | self.assertTrue(len(codes) == 1, 'Mixed responses: %s' % str(codes)) |
| 2735 | return codes.pop() |
| 2736 | |
| 2737 | === modified file 'lib/lp/services/librarianserver/tests/test_web.py' |
| 2738 | --- lib/lp/services/librarianserver/tests/test_web.py 2012-01-20 16:11:11 +0000 |
| 2739 | +++ lib/lp/services/librarianserver/tests/test_web.py 2012-07-03 08:07:22 +0000 |
| 2740 | @@ -373,7 +373,7 @@ |
| 2741 | try: |
| 2742 | urlopen(url) |
| 2743 | self.fail('404 not raised') |
| 2744 | - except HTTPError, e: |
| 2745 | + except HTTPError as e: |
| 2746 | self.failUnlessEqual(e.code, 404) |
| 2747 | |
| 2748 | |
| 2749 | @@ -479,5 +479,5 @@ |
| 2750 | try: |
| 2751 | urlopen(url) |
| 2752 | self.fail('404 not raised') |
| 2753 | - except HTTPError, x: |
| 2754 | + except HTTPError as x: |
| 2755 | self.failUnlessEqual(x.code, 404) |
| 2756 | |
| 2757 | === modified file 'lib/lp/services/mail/basemailer.py' |
| 2758 | --- lib/lp/services/mail/basemailer.py 2011-12-23 22:27:40 +0000 |
| 2759 | +++ lib/lp/services/mail/basemailer.py 2012-07-03 08:07:22 +0000 |
| 2760 | @@ -153,14 +153,14 @@ |
| 2761 | try: |
| 2762 | ctrl = self.generateEmail(email, recipient) |
| 2763 | ctrl.send() |
| 2764 | - except SMTPException, e: |
| 2765 | + except SMTPException as e: |
| 2766 | # If the initial sending failed, try again without |
| 2767 | # attachments. |
| 2768 | try: |
| 2769 | ctrl = self.generateEmail( |
| 2770 | email, recipient, force_no_attachments=True) |
| 2771 | ctrl.send() |
| 2772 | - except SMTPException, e: |
| 2773 | + except SMTPException as e: |
| 2774 | # Don't want an entire stack trace, just some details. |
| 2775 | self.logger.warning( |
| 2776 | 'send failed for %s, %s' % (email, e)) |
| 2777 | |
| 2778 | === modified file 'lib/lp/services/mail/incoming.py' |
| 2779 | --- lib/lp/services/mail/incoming.py 2012-04-16 00:14:36 +0000 |
| 2780 | +++ lib/lp/services/mail/incoming.py 2012-07-03 08:07:22 +0000 |
| 2781 | @@ -141,17 +141,17 @@ |
| 2782 | try: |
| 2783 | dkim_result = dkim.verify( |
| 2784 | signed_message.parsed_string, dkim_log, details=signing_details) |
| 2785 | - except dkim.DKIMException, e: |
| 2786 | + except dkim.DKIMException as e: |
| 2787 | log.warning('DKIM error: %r' % (e,)) |
| 2788 | - except dns.resolver.NXDOMAIN, e: |
| 2789 | + except dns.resolver.NXDOMAIN as e: |
| 2790 | # This can easily happen just through bad input data, ie claiming to |
| 2791 | # be signed by a domain with no visible key of that name. It's not an |
| 2792 | # operational error. |
| 2793 | log.info('DNS exception: %r' % (e,)) |
| 2794 | - except dns.exception.DNSException, e: |
| 2795 | + except dns.exception.DNSException as e: |
| 2796 | # many of them have lame messages, thus %r |
| 2797 | log.warning('DNS exception: %r' % (e,)) |
| 2798 | - except Exception, e: |
| 2799 | + except Exception as e: |
| 2800 | # DKIM leaks some errors when it gets bad input, as in bug 881237. We |
| 2801 | # don't generally want them to cause the mail to be dropped entirely |
| 2802 | # though. It probably is reasonable to treat them as potential |
| 2803 | @@ -307,7 +307,7 @@ |
| 2804 | sig = gpghandler.getVerifiedSignature( |
| 2805 | canonicalise_line_endings(mail.signedContent), signature) |
| 2806 | log.debug("got signature %r" % sig) |
| 2807 | - except GPGVerificationError, e: |
| 2808 | + except GPGVerificationError as e: |
| 2809 | # verifySignature failed to verify the signature. |
| 2810 | message = "Signature couldn't be verified: %s" % e |
| 2811 | log.debug(message) |
| 2812 | @@ -521,7 +521,7 @@ |
| 2813 | try: |
| 2814 | principal = authenticateEmail( |
| 2815 | mail, signature_timestamp_checker) |
| 2816 | - except InvalidSignature, error: |
| 2817 | + except InvalidSignature as error: |
| 2818 | send_process_error_notification( |
| 2819 | mail['From'], 'Submit Request Failure', str(error), mail) |
| 2820 | return |
| 2821 | @@ -534,7 +534,7 @@ |
| 2822 | |
| 2823 | try: |
| 2824 | do_paranoid_envelope_to_validation(addresses) |
| 2825 | - except AssertionError, e: |
| 2826 | + except AssertionError as e: |
| 2827 | log.info("Invalid email address: %s" % e) |
| 2828 | return |
| 2829 | |
| 2830 | |
| 2831 | === modified file 'lib/lp/services/mail/mailbox.py' |
| 2832 | --- lib/lp/services/mail/mailbox.py 2011-08-12 14:36:25 +0000 |
| 2833 | +++ lib/lp/services/mail/mailbox.py 2012-07-03 08:07:22 +0000 |
| 2834 | @@ -115,12 +115,12 @@ |
| 2835 | popbox = poplib.POP3_SSL(self._host) |
| 2836 | else: |
| 2837 | popbox = poplib.POP3(self._host) |
| 2838 | - except socket.error, e: |
| 2839 | + except socket.error as e: |
| 2840 | raise MailBoxError(str(e)) |
| 2841 | try: |
| 2842 | popbox.user(self._user) |
| 2843 | popbox.pass_(self._password) |
| 2844 | - except poplib.error_proto, e: |
| 2845 | + except poplib.error_proto as e: |
| 2846 | popbox.quit() |
| 2847 | raise MailBoxError(str(e)) |
| 2848 | self._popbox = popbox |
| 2849 | @@ -130,7 +130,7 @@ |
| 2850 | popbox = self._popbox |
| 2851 | try: |
| 2852 | count, size = popbox.stat() |
| 2853 | - except poplib.error_proto, e: |
| 2854 | + except poplib.error_proto as e: |
| 2855 | # This means we lost the connection. |
| 2856 | raise MailBoxError(str(e)) |
| 2857 | |
| 2858 | @@ -142,7 +142,7 @@ |
| 2859 | """See IMailBox.""" |
| 2860 | try: |
| 2861 | self._popbox.dele(id) |
| 2862 | - except poplib.error_proto, e: |
| 2863 | + except poplib.error_proto as e: |
| 2864 | raise MailBoxError(str(e)) |
| 2865 | |
| 2866 | def close(self): |
| 2867 | |
| 2868 | === modified file 'lib/lp/services/mailman/doc/logging.txt' |
| 2869 | --- lib/lp/services/mailman/doc/logging.txt 2012-01-01 02:25:04 +0000 |
| 2870 | +++ lib/lp/services/mailman/doc/logging.txt 2012-07-03 08:07:22 +0000 |
| 2871 | @@ -18,7 +18,7 @@ |
| 2872 | ... """Raise an error to test log_exception.""" |
| 2873 | ... try: |
| 2874 | ... raise AssertionError("There is an OOPS in progress.") |
| 2875 | - ... except AssertionError, error: |
| 2876 | + ... except AssertionError as error: |
| 2877 | ... log_exception('Generated Error: %s', error) |
| 2878 | |
| 2879 | >>> from lp.testing.fixture import CaptureOops |
| 2880 | |
| 2881 | === modified file 'lib/lp/services/mailman/monkeypatches/lphandler.py' |
| 2882 | --- lib/lp/services/mailman/monkeypatches/lphandler.py 2011-12-19 23:38:16 +0000 |
| 2883 | +++ lib/lp/services/mailman/monkeypatches/lphandler.py 2012-07-03 08:07:22 +0000 |
| 2884 | @@ -48,7 +48,7 @@ |
| 2885 | # processing at this handler. |
| 2886 | try: |
| 2887 | is_member = proxy.isRegisteredInLaunchpad(sender) |
| 2888 | - except Exception, error: |
| 2889 | + except Exception as error: |
| 2890 | XMLRPCRunner.handle_proxy_error(error, msg, msgdata) |
| 2891 | # This handler can just return if the sender is a member of Launchpad. |
| 2892 | if is_member: |
| 2893 | |
| 2894 | === modified file 'lib/lp/services/mailman/monkeypatches/lpstanding.py' |
| 2895 | --- lib/lp/services/mailman/monkeypatches/lpstanding.py 2011-01-18 02:42:08 +0000 |
| 2896 | +++ lib/lp/services/mailman/monkeypatches/lpstanding.py 2012-07-03 08:07:22 +0000 |
| 2897 | @@ -30,7 +30,7 @@ |
| 2898 | # processing at this handler. |
| 2899 | try: |
| 2900 | in_good_standing = proxy.inGoodStanding(sender) |
| 2901 | - except Exception, error: |
| 2902 | + except Exception as error: |
| 2903 | XMLRPCRunner.handle_proxy_error(error, msg, msgdata) |
| 2904 | # If the sender is a member in good standing, that's all we need to know |
| 2905 | # in order to let the message pass. |
| 2906 | |
| 2907 | === modified file 'lib/lp/services/mailman/monkeypatches/xmlrpcrunner.py' |
| 2908 | --- lib/lp/services/mailman/monkeypatches/xmlrpcrunner.py 2012-06-29 14:36:44 +0000 |
| 2909 | +++ lib/lp/services/mailman/monkeypatches/xmlrpcrunner.py 2012-07-03 08:07:22 +0000 |
| 2910 | @@ -172,10 +172,10 @@ |
| 2911 | """See if there are any list actions to perform.""" |
| 2912 | try: |
| 2913 | actions = self._proxy.getPendingActions() |
| 2914 | - except (xmlrpclib.ProtocolError, socket.error), error: |
| 2915 | + except (xmlrpclib.ProtocolError, socket.error) as error: |
| 2916 | log_exception('Cannot talk to Launchpad:\n%s', error) |
| 2917 | return |
| 2918 | - except xmlrpclib.Fault, error: |
| 2919 | + except xmlrpclib.Fault as error: |
| 2920 | log_exception('Launchpad exception: %s', error) |
| 2921 | return |
| 2922 | if actions: |
| 2923 | @@ -222,9 +222,9 @@ |
| 2924 | try: |
| 2925 | self._proxy.reportStatus(this_status) |
| 2926 | syslog('xmlrpc', '[%s] %s: %s' % (team_name, action, status)) |
| 2927 | - except (xmlrpclib.ProtocolError, socket.error), error: |
| 2928 | + except (xmlrpclib.ProtocolError, socket.error) as error: |
| 2929 | log_exception('Cannot talk to Launchpad:\n%s', error) |
| 2930 | - except xmlrpclib.Fault, error: |
| 2931 | + except xmlrpclib.Fault as error: |
| 2932 | log_exception('Launchpad exception: %s', error) |
| 2933 | |
| 2934 | def _update_list_subscriptions(self, list_name, subscription_info): |
| 2935 | @@ -354,11 +354,11 @@ |
| 2936 | # Get the information for this batch of mailing lists. |
| 2937 | try: |
| 2938 | info = self._proxy.getMembershipInformation(batch) |
| 2939 | - except (xmlrpclib.ProtocolError, socket.error), error: |
| 2940 | + except (xmlrpclib.ProtocolError, socket.error) as error: |
| 2941 | log_exception('Cannot talk to Launchpad: %s', error) |
| 2942 | syslog('xmlrpc', 'batch: %s', batch) |
| 2943 | continue |
| 2944 | - except xmlrpclib.Fault, error: |
| 2945 | + except xmlrpclib.Fault as error: |
| 2946 | log_exception('Launchpad exception: %s', error) |
| 2947 | syslog('xmlrpc', 'batch: %s', batch) |
| 2948 | continue |
| 2949 | @@ -409,7 +409,7 @@ |
| 2950 | mm_cfg.VAR_PREFIX, 'backups', team_name + '.tgz') |
| 2951 | try: |
| 2952 | tgz_file = tarfile.open(tgz_file_name, 'r:gz') |
| 2953 | - except IOError, error: |
| 2954 | + except IOError as error: |
| 2955 | if error.errno != errno.ENOENT: |
| 2956 | raise |
| 2957 | # The archive tarfile does not exist, meaning this is the |
| 2958 | @@ -593,10 +593,10 @@ |
| 2959 | """See if any held messages have been accepted or rejected.""" |
| 2960 | try: |
| 2961 | dispositions = self._proxy.getMessageDispositions() |
| 2962 | - except (xmlrpclib.ProtocolError, socket.error), error: |
| 2963 | + except (xmlrpclib.ProtocolError, socket.error) as error: |
| 2964 | log_exception('Cannot talk to Launchpad:\n%s', error) |
| 2965 | return |
| 2966 | - except xmlrpclib.Fault, error: |
| 2967 | + except xmlrpclib.Fault as error: |
| 2968 | log_exception('Launchpad exception: %s', error) |
| 2969 | return |
| 2970 | if dispositions: |
| 2971 | |
| 2972 | === modified file 'lib/lp/services/mailman/runmailman.py' |
| 2973 | --- lib/lp/services/mailman/runmailman.py 2011-12-30 09:38:59 +0000 |
| 2974 | +++ lib/lp/services/mailman/runmailman.py 2012-07-03 08:07:22 +0000 |
| 2975 | @@ -72,7 +72,7 @@ |
| 2976 | master_pid_path = os.path.join(mailman_path, 'data', 'master-qrunner.pid') |
| 2977 | try: |
| 2978 | master_pid_file = open(master_pid_path) |
| 2979 | - except IOError, error: |
| 2980 | + except IOError as error: |
| 2981 | if error.errno == errno.ENOENT: |
| 2982 | # It doesn't exist, so we're all done. |
| 2983 | return |
| 2984 | @@ -84,7 +84,7 @@ |
| 2985 | try: |
| 2986 | # Kill the entire process group. |
| 2987 | os.kill(master_pid, -signal.SIGKILL) |
| 2988 | - except OSError, error: |
| 2989 | + except OSError as error: |
| 2990 | if error.errno == errno.ESRCH: |
| 2991 | # The process does not exist. It could be a zombie that has yet |
| 2992 | # to be waited on, but let's not worry about that. |
| 2993 | @@ -92,7 +92,7 @@ |
| 2994 | raise |
| 2995 | try: |
| 2996 | os.remove(master_pid_path) |
| 2997 | - except OSError, error: |
| 2998 | + except OSError as error: |
| 2999 | if error.errno != errno.ENOENT: |
| 3000 | raise |
| 3001 | lock_dir = os.path.join(mailman_path, 'locks') |
| 3002 | |
| 3003 | === modified file 'lib/lp/services/mailman/testing/helpers.py' |
| 3004 | --- lib/lp/services/mailman/testing/helpers.py 2012-01-01 02:37:00 +0000 |
| 3005 | +++ lib/lp/services/mailman/testing/helpers.py 2012-07-03 08:07:22 +0000 |
| 3006 | @@ -71,7 +71,7 @@ |
| 3007 | """Return the size of a file, or -1 if it doesn't exist.""" |
| 3008 | try: |
| 3009 | return os.stat(path).st_size |
| 3010 | - except OSError, error: |
| 3011 | + except OSError as error: |
| 3012 | if error.errno == errno.ENOENT: |
| 3013 | # Return -1 when the file does not exist, so it always |
| 3014 | # compares less than an existing but empty file. |
| 3015 | @@ -214,7 +214,7 @@ |
| 3016 | archived_files = [file_name |
| 3017 | for file_name in os.listdir(mhonarc_path) |
| 3018 | if file_name.endswith('.html')] |
| 3019 | - except OSError, error: |
| 3020 | + except OSError as error: |
| 3021 | if error.errno != errno.ENOENT: |
| 3022 | raise |
| 3023 | # Sleep and try again. |
| 3024 | |
| 3025 | === modified file 'lib/lp/services/mailman/tests/test_mailman.py' |
| 3026 | --- lib/lp/services/mailman/tests/test_mailman.py 2012-01-01 02:58:52 +0000 |
| 3027 | +++ lib/lp/services/mailman/tests/test_mailman.py 2012-07-03 08:07:22 +0000 |
| 3028 | @@ -83,14 +83,14 @@ |
| 3029 | VAR_PREFIX, 'backups', '%s.tgz' % team_name) |
| 3030 | try: |
| 3031 | os.remove(backup_file) |
| 3032 | - except OSError, error: |
| 3033 | + except OSError as error: |
| 3034 | if error.errno != errno.ENOENT: |
| 3035 | raise |
| 3036 | # Delete the MHonArc archives if they exist. |
| 3037 | path = os.path.join(VAR_PREFIX, 'mhonarc', team_name) |
| 3038 | try: |
| 3039 | shutil.rmtree(path) |
| 3040 | - except OSError, error: |
| 3041 | + except OSError as error: |
| 3042 | if error.errno != errno.ENOENT: |
| 3043 | raise |
| 3044 | # Remove all held messages. |
| 3045 | |
| 3046 | === modified file 'lib/lp/services/messaging/rabbit.py' |
| 3047 | --- lib/lp/services/messaging/rabbit.py 2012-04-24 04:23:52 +0000 |
| 3048 | +++ lib/lp/services/messaging/rabbit.py 2012-07-03 08:07:22 +0000 |
| 3049 | @@ -281,7 +281,7 @@ |
| 3050 | else: |
| 3051 | self.channel.basic_ack(message.delivery_tag) |
| 3052 | return json.loads(message.body) |
| 3053 | - except amqp.AMQPChannelException, error: |
| 3054 | + except amqp.AMQPChannelException as error: |
| 3055 | if error.amqp_reply_code == 404: |
| 3056 | raise QueueNotFound() |
| 3057 | else: |
| 3058 | |
| 3059 | === modified file 'lib/lp/services/osutils.py' |
| 3060 | --- lib/lp/services/osutils.py 2012-05-31 11:46:17 +0000 |
| 3061 | +++ lib/lp/services/osutils.py 2012-07-03 08:07:22 +0000 |
| 3062 | @@ -79,11 +79,11 @@ |
| 3063 | for i in range(retries): |
| 3064 | try: |
| 3065 | return function(*args, **kwargs) |
| 3066 | - except (IOError, OSError), e: |
| 3067 | + except (IOError, OSError) as e: |
| 3068 | if e.errno == errno.EINTR: |
| 3069 | continue |
| 3070 | raise |
| 3071 | - except socket.error, e: |
| 3072 | + except socket.error as e: |
| 3073 | # In Python 2.6 we can use IOError instead. It also has |
| 3074 | # reason.errno but we might be using 2.5 here so use the |
| 3075 | # index hack. |
| 3076 | @@ -101,7 +101,7 @@ |
| 3077 | """ |
| 3078 | try: |
| 3079 | os.makedirs(directory, mode=mode) |
| 3080 | - except OSError, e: |
| 3081 | + except OSError as e: |
| 3082 | if e.errno == errno.EEXIST: |
| 3083 | return False |
| 3084 | raise |
| 3085 | @@ -121,7 +121,7 @@ |
| 3086 | """ |
| 3087 | try: |
| 3088 | return open(filename, mode) |
| 3089 | - except IOError, e: |
| 3090 | + except IOError as e: |
| 3091 | if e.errno == errno.ENOENT: |
| 3092 | os.makedirs(os.path.dirname(filename), mode=dirmode) |
| 3093 | return open(filename, mode) |
| 3094 | @@ -131,7 +131,7 @@ |
| 3095 | """Kill a pid accepting that it may not exist.""" |
| 3096 | try: |
| 3097 | os.kill(pid, signal_number) |
| 3098 | - except OSError, e: |
| 3099 | + except OSError as e: |
| 3100 | if e.errno in (errno.ESRCH, errno.ECHILD): |
| 3101 | # Process has already been killed. |
| 3102 | return |
| 3103 | @@ -159,7 +159,7 @@ |
| 3104 | if new_pid: |
| 3105 | return result |
| 3106 | time.sleep(poll_interval) |
| 3107 | - except OSError, e: |
| 3108 | + except OSError as e: |
| 3109 | if e.errno in (errno.ESRCH, errno.ECHILD): |
| 3110 | # Raised if the process is gone by the time we try to get the |
| 3111 | # return value. |
| 3112 | @@ -201,7 +201,7 @@ |
| 3113 | """Remove the given file if it exists.""" |
| 3114 | try: |
| 3115 | os.remove(path) |
| 3116 | - except OSError, e: |
| 3117 | + except OSError as e: |
| 3118 | if e.errno != errno.ENOENT: |
| 3119 | raise |
| 3120 | |
| 3121 | |
| 3122 | === modified file 'lib/lp/services/salesforce/proxy.py' |
| 3123 | --- lib/lp/services/salesforce/proxy.py 2011-12-30 08:13:14 +0000 |
| 3124 | +++ lib/lp/services/salesforce/proxy.py 2012-07-03 08:07:22 +0000 |
| 3125 | @@ -46,7 +46,7 @@ |
| 3126 | def decorator(*args, **kwargs): |
| 3127 | try: |
| 3128 | results = func(*args, **kwargs) |
| 3129 | - except Fault, fault: |
| 3130 | + except Fault as fault: |
| 3131 | exception = errorcode_map.get(fault.faultCode, |
| 3132 | SalesforceVoucherProxyException) |
| 3133 | raise exception(fault.faultString) |
| 3134 | |
| 3135 | === modified file 'lib/lp/services/scripts/base.py' |
| 3136 | --- lib/lp/services/scripts/base.py 2012-05-31 10:30:03 +0000 |
| 3137 | +++ lib/lp/services/scripts/base.py 2012-07-03 08:07:22 +0000 |
| 3138 | @@ -339,10 +339,10 @@ |
| 3139 | profiler.runcall(self.main) |
| 3140 | else: |
| 3141 | self.main() |
| 3142 | - except LaunchpadScriptFailure, e: |
| 3143 | + except LaunchpadScriptFailure as e: |
| 3144 | self.logger.error(str(e)) |
| 3145 | sys.exit(e.exit_status) |
| 3146 | - except SilentLaunchpadScriptFailure, e: |
| 3147 | + except SilentLaunchpadScriptFailure as e: |
| 3148 | sys.exit(e.exit_status) |
| 3149 | else: |
| 3150 | date_completed = datetime.datetime.now(UTC) |
| 3151 | @@ -457,13 +457,13 @@ |
| 3152 | # seconds. |
| 3153 | control_fp = urlopen(control_url, timeout=5) |
| 3154 | # Yuck. API makes it hard to catch 'does not exist'. |
| 3155 | - except HTTPError, error: |
| 3156 | + except HTTPError as error: |
| 3157 | if error.code == 404: |
| 3158 | log.debug("Cronscript control file not found at %s", control_url) |
| 3159 | return True |
| 3160 | log.exception("Error loading %s" % control_url) |
| 3161 | return True |
| 3162 | - except URLError, error: |
| 3163 | + except URLError as error: |
| 3164 | if getattr(error.reason, 'errno', None) == 2: |
| 3165 | log.debug("Cronscript control file not found at %s", control_url) |
| 3166 | return True |
| 3167 | |
| 3168 | === modified file 'lib/lp/services/temporaryblobstorage/browser.py' |
| 3169 | --- lib/lp/services/temporaryblobstorage/browser.py 2011-12-30 02:24:09 +0000 |
| 3170 | +++ lib/lp/services/temporaryblobstorage/browser.py 2012-07-03 08:07:22 +0000 |
| 3171 | @@ -64,7 +64,7 @@ |
| 3172 | except BlobTooLarge: |
| 3173 | self.addError('Uploaded file was too large.') |
| 3174 | return None |
| 3175 | - except UploadFailed, e: |
| 3176 | + except UploadFailed as e: |
| 3177 | self.addError('File storage unavailable - try again later.') |
| 3178 | return None |
| 3179 | else: |
| 3180 | |
| 3181 | === modified file 'lib/lp/services/twistedsupport/__init__.py' |
| 3182 | --- lib/lp/services/twistedsupport/__init__.py 2011-06-20 20:07:33 +0000 |
| 3183 | +++ lib/lp/services/twistedsupport/__init__.py 2012-07-03 08:07:22 +0000 |
| 3184 | @@ -137,7 +137,7 @@ |
| 3185 | def wrapped(*args, **kwargs): |
| 3186 | try: |
| 3187 | return func(*args, **kwargs) |
| 3188 | - except BaseException, e: |
| 3189 | + except BaseException as e: |
| 3190 | return Failure(e) |
| 3191 | |
| 3192 | return wrapped |
| 3193 | |
| 3194 | === modified file 'lib/lp/services/twistedsupport/tests/test_xmlrpc.py' |
| 3195 | --- lib/lp/services/twistedsupport/tests/test_xmlrpc.py 2010-10-30 23:15:55 +0000 |
| 3196 | +++ lib/lp/services/twistedsupport/tests/test_xmlrpc.py 2012-07-03 08:07:22 +0000 |
| 3197 | @@ -52,7 +52,7 @@ |
| 3198 | def assertRaisesFailure(self, failure, function, *args, **kwargs): |
| 3199 | try: |
| 3200 | function(*args, **kwargs) |
| 3201 | - except Failure, raised_failure: |
| 3202 | + except Failure as raised_failure: |
| 3203 | self.assertEqual(failure, raised_failure) |
| 3204 | |
| 3205 | def test_raises_non_faults(self): |
| 3206 | |
| 3207 | === modified file 'lib/lp/services/verification/browser/logintoken.py' |
| 3208 | --- lib/lp/services/verification/browser/logintoken.py 2012-06-13 21:40:11 +0000 |
| 3209 | +++ lib/lp/services/verification/browser/logintoken.py 2012-07-03 08:07:22 +0000 |
| 3210 | @@ -246,7 +246,7 @@ |
| 3211 | try: |
| 3212 | self.claimed_profile.convertToTeam( |
| 3213 | team_owner=self.context.requester) |
| 3214 | - except AlreadyConvertedException, e: |
| 3215 | + except AlreadyConvertedException as e: |
| 3216 | self.request.response.addErrorNotification(e) |
| 3217 | self.context.consume() |
| 3218 | return |
| 3219 | @@ -316,7 +316,7 @@ |
| 3220 | try: |
| 3221 | signature = getUtility(IGPGHandler).getVerifiedSignature( |
| 3222 | signedcontent.encode('ASCII')) |
| 3223 | - except (GPGVerificationError, UnicodeEncodeError), e: |
| 3224 | + except (GPGVerificationError, UnicodeEncodeError) as e: |
| 3225 | self.addError(_( |
| 3226 | 'Launchpad could not verify your signature: ${err}', |
| 3227 | mapping=dict(err=str(e)))) |
| 3228 | @@ -401,7 +401,7 @@ |
| 3229 | 'YOU</kdb>). Try later or <a href="${url}/+editpgpkeys"> ' |
| 3230 | 'cancel your request</a>.', |
| 3231 | mapping=dict(fingerprint=fingerprint, url=person_url)))) |
| 3232 | - except GPGKeyRevoked, e: |
| 3233 | + except GPGKeyRevoked as e: |
| 3234 | # If key is globally revoked, skip the import and consume the |
| 3235 | # token. |
| 3236 | self.addError( |
| 3237 | @@ -412,7 +412,7 @@ |
| 3238 | 'process to <a href="${url}/+editpgpkeys">find and ' |
| 3239 | 'import</a> the new key.', |
| 3240 | mapping=dict(key=e.key.keyid, url=person_url)))) |
| 3241 | - except GPGKeyExpired, e: |
| 3242 | + except GPGKeyExpired as e: |
| 3243 | self.addError( |
| 3244 | structured(_( |
| 3245 | 'The key ${key} cannot be validated because it has expired. ' |
| 3246 | |
| 3247 | === modified file 'lib/lp/services/webapp/adapter.py' |
| 3248 | --- lib/lp/services/webapp/adapter.py 2012-04-06 17:28:25 +0000 |
| 3249 | +++ lib/lp/services/webapp/adapter.py 2012-07-03 08:07:22 +0000 |
| 3250 | @@ -481,7 +481,7 @@ |
| 3251 | try: |
| 3252 | return super(ReadOnlyModeConnection, self).execute( |
| 3253 | statement, params, noresult) |
| 3254 | - except psycopg2.InternalError, exception: |
| 3255 | + except psycopg2.InternalError as exception: |
| 3256 | # Error 25006 is 'ERROR: transaction is read-only'. This |
| 3257 | # is raised when an attempt is made to make changes when |
| 3258 | # the connection has been put in read-only mode. |
| 3259 | |
| 3260 | === modified file 'lib/lp/services/webapp/batching.py' |
| 3261 | --- lib/lp/services/webapp/batching.py 2012-03-26 04:35:37 +0000 |
| 3262 | +++ lib/lp/services/webapp/batching.py 2012-07-03 08:07:22 +0000 |
| 3263 | @@ -387,7 +387,7 @@ |
| 3264 | expression = plain_expression(expression) |
| 3265 | try: |
| 3266 | expression.variable_factory(value=value) |
| 3267 | - except TypeError, error: |
| 3268 | + except TypeError as error: |
| 3269 | # A TypeError is raised when the type of value cannot |
| 3270 | # be used for expression. All expected types are |
| 3271 | # properly created by simplejson.loads() above, except |
| 3272 | |
| 3273 | === modified file 'lib/lp/services/webapp/publisher.py' |
| 3274 | --- lib/lp/services/webapp/publisher.py 2012-06-14 05:18:22 +0000 |
| 3275 | +++ lib/lp/services/webapp/publisher.py 2012-07-03 08:07:22 +0000 |
| 3276 | @@ -325,7 +325,7 @@ |
| 3277 | # infrastructure. |
| 3278 | try: |
| 3279 | cache = IJSONRequestCache(self.request).objects |
| 3280 | - except TypeError, error: |
| 3281 | + except TypeError as error: |
| 3282 | if error.args[0] == 'Could not adapt': |
| 3283 | cache = None |
| 3284 | return cache |
| 3285 | |
| 3286 | === modified file 'lib/lp/services/webapp/tests/test_error.py' |
| 3287 | --- lib/lp/services/webapp/tests/test_error.py 2012-06-22 15:37:20 +0000 |
| 3288 | +++ lib/lp/services/webapp/tests/test_error.py 2012-07-03 08:07:22 +0000 |
| 3289 | @@ -62,7 +62,7 @@ |
| 3290 | def getHTTPError(self, url): |
| 3291 | try: |
| 3292 | urllib2.urlopen(url) |
| 3293 | - except urllib2.HTTPError, error: |
| 3294 | + except urllib2.HTTPError as error: |
| 3295 | return error |
| 3296 | else: |
| 3297 | self.fail("We should have gotten an HTTP error") |
| 3298 | |
| 3299 | === modified file 'lib/lp/services/webapp/tests/test_errorlog.py' |
| 3300 | --- lib/lp/services/webapp/tests/test_errorlog.py 2012-05-15 07:15:17 +0000 |
| 3301 | +++ lib/lp/services/webapp/tests/test_errorlog.py 2012-07-03 08:07:22 +0000 |
| 3302 | @@ -715,7 +715,7 @@ |
| 3303 | converter = module.get_converter('int') |
| 3304 | try: |
| 3305 | converter(42) |
| 3306 | - except ValueError, e: |
| 3307 | + except ValueError as e: |
| 3308 | self.assertTrue(IUnloggedException.providedBy(e)) |
| 3309 | |
| 3310 | def test_other_errors_not_marked(self): |
| 3311 | @@ -734,7 +734,7 @@ |
| 3312 | converter = module.get_converter('int') |
| 3313 | try: |
| 3314 | converter(42) |
| 3315 | - except RuntimeError, e: |
| 3316 | + except RuntimeError as e: |
| 3317 | self.assertFalse(IUnloggedException.providedBy(e)) |
| 3318 | |
| 3319 | def test_none_is_not_wrapped(self): |
| 3320 | |
| 3321 | === modified file 'lib/lp/services/webservice/doc/webservice-error.txt' |
| 3322 | --- lib/lp/services/webservice/doc/webservice-error.txt 2011-12-24 17:49:30 +0000 |
| 3323 | +++ lib/lp/services/webservice/doc/webservice-error.txt 2012-07-03 08:07:22 +0000 |
| 3324 | @@ -17,7 +17,7 @@ |
| 3325 | ... """ |
| 3326 | ... try: |
| 3327 | ... raise error |
| 3328 | - ... except Exception, error: |
| 3329 | + ... except Exception as error: |
| 3330 | ... request = LaunchpadTestRequest( |
| 3331 | ... environ={'PATH_INFO' : ''}) |
| 3332 | ... set_request_started() |
| 3333 | |
| 3334 | === modified file 'lib/lp/soyuz/adapters/packagelocation.py' |
| 3335 | --- lib/lp/soyuz/adapters/packagelocation.py 2010-08-23 16:51:11 +0000 |
| 3336 | +++ lib/lp/soyuz/adapters/packagelocation.py 2012-07-03 08:07:22 +0000 |
| 3337 | @@ -101,7 +101,7 @@ |
| 3338 | |
| 3339 | try: |
| 3340 | distribution = getUtility(IDistributionSet)[distribution_name] |
| 3341 | - except NotFoundError, err: |
| 3342 | + except NotFoundError as err: |
| 3343 | raise PackageLocationError( |
| 3344 | "Could not find distribution %s" % err) |
| 3345 | |
| 3346 | @@ -147,7 +147,7 @@ |
| 3347 | try: |
| 3348 | distroseries, pocket = distribution.getDistroSeriesAndPocket( |
| 3349 | suite) |
| 3350 | - except NotFoundError, err: |
| 3351 | + except NotFoundError as err: |
| 3352 | raise PackageLocationError( |
| 3353 | "Could not find suite %s" % err) |
| 3354 | else: |
| 3355 | @@ -161,7 +161,7 @@ |
| 3356 | try: |
| 3357 | packageset = packageset_set.getByName( |
| 3358 | packageset_name, distroseries=distroseries) |
| 3359 | - except NotFoundError, err: |
| 3360 | + except NotFoundError as err: |
| 3361 | raise PackageLocationError( |
| 3362 | "Could not find packageset %s" % err) |
| 3363 | packagesets.append(packageset) |
| 3364 | |
| 3365 | === modified file 'lib/lp/soyuz/browser/archive.py' |
| 3366 | --- lib/lp/soyuz/browser/archive.py 2012-06-28 14:45:12 +0000 |
| 3367 | +++ lib/lp/soyuz/browser/archive.py 2012-07-03 08:07:22 +0000 |
| 3368 | @@ -1435,7 +1435,7 @@ |
| 3369 | dest_display_name=dest_display_name, person=person, |
| 3370 | check_permissions=check_permissions, |
| 3371 | sponsored=sponsored_person) |
| 3372 | - except CannotCopy, error: |
| 3373 | + except CannotCopy as error: |
| 3374 | self.setFieldError( |
| 3375 | sources_field_name, render_cannotcopy_as_html(error)) |
| 3376 | return False |
| 3377 | |
| 3378 | === modified file 'lib/lp/soyuz/browser/queue.py' |
| 3379 | --- lib/lp/soyuz/browser/queue.py 2012-01-01 02:58:52 +0000 |
| 3380 | +++ lib/lp/soyuz/browser/queue.py 2012-07-03 08:07:22 +0000 |
| 3381 | @@ -388,7 +388,7 @@ |
| 3382 | binary_overridden = queue_item.overrideBinaries( |
| 3383 | new_component, new_section, new_priority, |
| 3384 | allowed_components) |
| 3385 | - except QueueInconsistentStateError, info: |
| 3386 | + except QueueInconsistentStateError as info: |
| 3387 | failure.append("FAILED: %s (%s)" % |
| 3388 | (queue_item.displayname, info)) |
| 3389 | continue |
| 3390 | @@ -409,7 +409,7 @@ |
| 3391 | |
| 3392 | try: |
| 3393 | getattr(self, 'queue_action_' + action)(queue_item) |
| 3394 | - except QueueInconsistentStateError, info: |
| 3395 | + except QueueInconsistentStateError as info: |
| 3396 | failure.append('FAILED: %s (%s)' % |
| 3397 | (queue_item.displayname, info)) |
| 3398 | else: |
| 3399 | |
| 3400 | === modified file 'lib/lp/soyuz/doc/distroseriesqueue.txt' |
| 3401 | --- lib/lp/soyuz/doc/distroseriesqueue.txt 2012-01-06 11:08:30 +0000 |
| 3402 | +++ lib/lp/soyuz/doc/distroseriesqueue.txt 2012-07-03 08:07:22 +0000 |
| 3403 | @@ -97,7 +97,7 @@ |
| 3404 | ... try: |
| 3405 | ... item.setAccepted() |
| 3406 | ... item.syncUpdate() |
| 3407 | - ... except QueueInconsistentStateError, info: |
| 3408 | + ... except QueueInconsistentStateError as info: |
| 3409 | ... print info |
| 3410 | |
| 3411 | >>> accepted_queue = hoary.getPackageUploads(PackageUploadStatus.ACCEPTED) |
| 3412 | @@ -308,7 +308,7 @@ |
| 3413 | >>> for item in items: |
| 3414 | ... try: |
| 3415 | ... item.setAccepted() |
| 3416 | - ... except QueueInconsistentStateError, e: |
| 3417 | + ... except QueueInconsistentStateError as e: |
| 3418 | ... print item.displayname, e |
| 3419 | ... else: |
| 3420 | ... print item.displayname, item.status.name |
| 3421 | @@ -339,7 +339,7 @@ |
| 3422 | >>> for item in items: |
| 3423 | ... try: |
| 3424 | ... item.setNew() |
| 3425 | - ... except QueueInconsistentStateError, e: |
| 3426 | + ... except QueueInconsistentStateError as e: |
| 3427 | ... print item.displayname, e |
| 3428 | ... else: |
| 3429 | ... print item.displayname, 'BOGUS' |
| 3430 | @@ -380,7 +380,7 @@ |
| 3431 | >>> naked_bin.component = getUtility(IComponentSet).new('hell') |
| 3432 | >>> try: |
| 3433 | ... item.setAccepted() |
| 3434 | - ... except QueueInconsistentStateError, e: |
| 3435 | + ... except QueueInconsistentStateError as e: |
| 3436 | ... print item.displayname, e |
| 3437 | ... else: |
| 3438 | ... print item.displayname, 'ACCEPTED' |
| 3439 | @@ -839,7 +839,7 @@ |
| 3440 | >>> insertFakeChangesFile(items[3].changesfile.id) |
| 3441 | >>> try: |
| 3442 | ... items[1].acceptFromQueue() |
| 3443 | - ... except QueueInconsistentStateError, e: |
| 3444 | + ... except QueueInconsistentStateError as e: |
| 3445 | ... print 'FAILED' |
| 3446 | ... else: |
| 3447 | ... print 'DONE' |
| 3448 | @@ -870,7 +870,7 @@ |
| 3449 | |
| 3450 | >>> try: |
| 3451 | ... items[3].rejectFromQueue() |
| 3452 | - ... except QueueInconsistentStateError, e: |
| 3453 | + ... except QueueInconsistentStateError as e: |
| 3454 | ... print 'FAILED' |
| 3455 | ... else: |
| 3456 | ... print 'REJECTED' |
| 3457 | |
| 3458 | === modified file 'lib/lp/soyuz/doc/manage-chroot.txt' |
| 3459 | --- lib/lp/soyuz/doc/manage-chroot.txt 2012-01-19 03:09:09 +0000 |
| 3460 | +++ lib/lp/soyuz/doc/manage-chroot.txt 2012-07-03 08:07:22 +0000 |
| 3461 | @@ -86,7 +86,7 @@ |
| 3462 | >>> manage_chroot = getScriptObject("bogus") |
| 3463 | >>> try: |
| 3464 | ... manage_chroot.mainTask() |
| 3465 | - ... except SoyuzScriptError, info: |
| 3466 | + ... except SoyuzScriptError as info: |
| 3467 | ... print info |
| 3468 | ... else: |
| 3469 | ... print "Did not get expected exception" |
| 3470 | @@ -99,7 +99,7 @@ |
| 3471 | >>> manage_chroot = getScriptObject("add", arch="bogus") |
| 3472 | >>> try: |
| 3473 | ... manage_chroot.mainTask() |
| 3474 | - ... except SoyuzScriptError, info: |
| 3475 | + ... except SoyuzScriptError as info: |
| 3476 | ... print info |
| 3477 | ... else: |
| 3478 | ... print "Did not get expected exception" |
| 3479 | @@ -125,7 +125,7 @@ |
| 3480 | >>> manage_chroot = getScriptObject("add", filepath=filepath) |
| 3481 | >>> try: |
| 3482 | ... manage_chroot.mainTask() |
| 3483 | - ... except SoyuzScriptError, info: |
| 3484 | + ... except SoyuzScriptError as info: |
| 3485 | ... print info |
| 3486 | ... else: |
| 3487 | ... print "Did not get expected exception" |
| 3488 | @@ -171,7 +171,7 @@ |
| 3489 | >>> manage_chroot = getScriptObject("get", filepath=filepath) |
| 3490 | >>> try: |
| 3491 | ... manage_chroot.mainTask() |
| 3492 | - ... except SoyuzScriptError, info: |
| 3493 | + ... except SoyuzScriptError as info: |
| 3494 | ... print info |
| 3495 | ... else: |
| 3496 | ... print "Did not get expected exception" |
| 3497 | @@ -190,7 +190,7 @@ |
| 3498 | >>> manage_chroot = getScriptObject("add", filepath=filepath) |
| 3499 | >>> try: |
| 3500 | ... manage_chroot.mainTask() |
| 3501 | - ... except SoyuzScriptError, info: |
| 3502 | + ... except SoyuzScriptError as info: |
| 3503 | ... print info |
| 3504 | ... else: |
| 3505 | ... print "Did not get expected exception" |
| 3506 | |
| 3507 | === modified file 'lib/lp/soyuz/doc/soyuz-upload.txt' |
| 3508 | --- lib/lp/soyuz/doc/soyuz-upload.txt 2012-04-17 08:32:44 +0000 |
| 3509 | +++ lib/lp/soyuz/doc/soyuz-upload.txt 2012-07-03 08:07:22 +0000 |
| 3510 | @@ -405,7 +405,7 @@ |
| 3511 | >>> for queue_item in queue_items: |
| 3512 | ... try: |
| 3513 | ... queue_item.setAccepted() |
| 3514 | - ... except QueueInconsistentStateError, e: |
| 3515 | + ... except QueueInconsistentStateError as e: |
| 3516 | ... L.append("%s %s" % (queue_item.sourcepackagerelease.name, e)) |
| 3517 | ... else: |
| 3518 | ... L.append("%s %s" % (queue_item.sourcepackagerelease.name, |
| 3519 | |
| 3520 | === modified file 'lib/lp/soyuz/model/binarypackagebuild.py' |
| 3521 | --- lib/lp/soyuz/model/binarypackagebuild.py 2012-06-19 03:26:57 +0000 |
| 3522 | +++ lib/lp/soyuz/model/binarypackagebuild.py 2012-07-03 08:07:22 +0000 |
| 3523 | @@ -855,7 +855,7 @@ |
| 3524 | """See `IBinaryPackageBuildSet`.""" |
| 3525 | try: |
| 3526 | return BinaryPackageBuild.get(id) |
| 3527 | - except SQLObjectNotFound, e: |
| 3528 | + except SQLObjectNotFound as e: |
| 3529 | raise NotFoundError(str(e)) |
| 3530 | |
| 3531 | def getByBuildFarmJob(self, build_farm_job): |
| 3532 | @@ -1179,7 +1179,7 @@ |
| 3533 | build = IMasterObject(build) |
| 3534 | try: |
| 3535 | build.updateDependencies() |
| 3536 | - except UnparsableDependencies, e: |
| 3537 | + except UnparsableDependencies as e: |
| 3538 | logger.error(e) |
| 3539 | continue |
| 3540 | |
| 3541 | |
| 3542 | === modified file 'lib/lp/soyuz/model/packagecopyjob.py' |
| 3543 | --- lib/lp/soyuz/model/packagecopyjob.py 2012-06-28 12:21:01 +0000 |
| 3544 | +++ lib/lp/soyuz/model/packagecopyjob.py 2012-07-03 08:07:22 +0000 |
| 3545 | @@ -493,7 +493,7 @@ |
| 3546 | """See `IRunnableJob`.""" |
| 3547 | try: |
| 3548 | self.attemptCopy() |
| 3549 | - except CannotCopy, e: |
| 3550 | + except CannotCopy as e: |
| 3551 | logger = logging.getLogger() |
| 3552 | logger.info("Job:\n%s\nraised CannotCopy:\n%s" % (self, e)) |
| 3553 | self.abort() # Abort the txn. |
| 3554 | |
| 3555 | === modified file 'lib/lp/soyuz/model/publishing.py' |
| 3556 | --- lib/lp/soyuz/model/publishing.py 2012-06-19 16:09:38 +0000 |
| 3557 | +++ lib/lp/soyuz/model/publishing.py 2012-07-03 08:07:22 +0000 |
| 3558 | @@ -313,7 +313,7 @@ |
| 3559 | try: |
| 3560 | for pub_file in self.files: |
| 3561 | pub_file.publish(diskpool, log) |
| 3562 | - except PoolFileOverwriteError, e: |
| 3563 | + except PoolFileOverwriteError as e: |
| 3564 | message = "PoolFileOverwriteError: %s, skipping." % e |
| 3565 | properties = [('error-explanation', message)] |
| 3566 | request = ScriptRequest(properties) |
| 3567 | |
| 3568 | === modified file 'lib/lp/soyuz/model/queue.py' |
| 3569 | --- lib/lp/soyuz/model/queue.py 2012-06-30 23:34:51 +0000 |
| 3570 | +++ lib/lp/soyuz/model/queue.py 2012-07-03 08:07:22 +0000 |
| 3571 | @@ -293,7 +293,7 @@ |
| 3572 | # Mask the error with state-machine default exception |
| 3573 | try: |
| 3574 | source.checkComponentAndSection() |
| 3575 | - except QueueSourceAcceptError, info: |
| 3576 | + except QueueSourceAcceptError as info: |
| 3577 | raise QueueInconsistentStateError(info) |
| 3578 | |
| 3579 | self._checkForBinariesinDestinationArchive( |
| 3580 | @@ -301,7 +301,7 @@ |
| 3581 | for queue_build in self.builds: |
| 3582 | try: |
| 3583 | queue_build.checkComponentAndSection() |
| 3584 | - except QueueBuildAcceptError, info: |
| 3585 | + except QueueBuildAcceptError as info: |
| 3586 | raise QueueInconsistentStateError(info) |
| 3587 | |
| 3588 | # if the previous checks applied and pass we do set the value |
| 3589 | @@ -754,7 +754,7 @@ |
| 3590 | for customfile in self.customfiles: |
| 3591 | try: |
| 3592 | customfile.publish(logger) |
| 3593 | - except CustomUploadError, e: |
| 3594 | + except CustomUploadError as e: |
| 3595 | if logger is not None: |
| 3596 | logger.error("Queue item ignored: %s" % e) |
| 3597 | return [] |
| 3598 | |
| 3599 | === modified file 'lib/lp/soyuz/scripts/add_missing_builds.py' |
| 3600 | --- lib/lp/soyuz/scripts/add_missing_builds.py 2012-01-01 02:58:52 +0000 |
| 3601 | +++ lib/lp/soyuz/scripts/add_missing_builds.py 2012-07-03 08:07:22 +0000 |
| 3602 | @@ -87,7 +87,7 @@ |
| 3603 | """Entry point for `LaunchpadScript`s.""" |
| 3604 | try: |
| 3605 | self.setupLocation() |
| 3606 | - except SoyuzScriptError, err: |
| 3607 | + except SoyuzScriptError as err: |
| 3608 | raise LaunchpadScriptFailure(err) |
| 3609 | |
| 3610 | if not self.options.arch_tags: |
| 3611 | @@ -113,7 +113,7 @@ |
| 3612 | self.location.distroseries, self.location.pocket) |
| 3613 | self.txn.commit() |
| 3614 | self.logger.info("Finished adding builds.") |
| 3615 | - except Exception, err: |
| 3616 | + except Exception as err: |
| 3617 | self.logger.error(err) |
| 3618 | self.txn.abort() |
| 3619 | self.logger.info("Errors, aborted transaction.") |
| 3620 | |
| 3621 | === modified file 'lib/lp/soyuz/scripts/buildd.py' |
| 3622 | --- lib/lp/soyuz/scripts/buildd.py 2012-01-01 02:58:52 +0000 |
| 3623 | +++ lib/lp/soyuz/scripts/buildd.py 2012-07-03 08:07:22 +0000 |
| 3624 | @@ -211,7 +211,7 @@ |
| 3625 | try: |
| 3626 | distroseries, pocket = distribution.getDistroSeriesAndPocket( |
| 3627 | suite) |
| 3628 | - except NotFoundError, err: |
| 3629 | + except NotFoundError as err: |
| 3630 | raise LaunchpadScriptFailure("Could not find suite %s" % err) |
| 3631 | distroseries_set.add(distroseries) |
| 3632 | |
| 3633 | |
| 3634 | === modified file 'lib/lp/soyuz/scripts/chrootmanager.py' |
| 3635 | --- lib/lp/soyuz/scripts/chrootmanager.py 2012-01-19 03:06:04 +0000 |
| 3636 | +++ lib/lp/soyuz/scripts/chrootmanager.py 2012-07-03 08:07:22 +0000 |
| 3637 | @@ -71,7 +71,7 @@ |
| 3638 | try: |
| 3639 | alias_id = getUtility(ILibrarianClient).addFile( |
| 3640 | filename, flen, fd, contentType=ftype) |
| 3641 | - except UploadFailed, info: |
| 3642 | + except UploadFailed as info: |
| 3643 | raise ChrootManagerError("Librarian upload failed: %s" % info) |
| 3644 | |
| 3645 | lfa = getUtility(ILibraryFileAliasSet)[alias_id] |
| 3646 | @@ -201,7 +201,7 @@ |
| 3647 | |
| 3648 | try: |
| 3649 | distroarchseries = series[self.options.architecture] |
| 3650 | - except NotFoundError, info: |
| 3651 | + except NotFoundError as info: |
| 3652 | raise SoyuzScriptError("Architecture not found: %s" % info) |
| 3653 | |
| 3654 | # We don't want to have to force the user to confirm transactions |
| 3655 | @@ -222,7 +222,7 @@ |
| 3656 | |
| 3657 | try: |
| 3658 | chroot_action() |
| 3659 | - except ChrootManagerError, info: |
| 3660 | + except ChrootManagerError as info: |
| 3661 | raise SoyuzScriptError(info) |
| 3662 | else: |
| 3663 | # Collect extra debug messages from chroot_manager. |
| 3664 | |
| 3665 | === modified file 'lib/lp/soyuz/scripts/ftpmasterbase.py' |
| 3666 | --- lib/lp/soyuz/scripts/ftpmasterbase.py 2012-06-19 17:32:05 +0000 |
| 3667 | +++ lib/lp/soyuz/scripts/ftpmasterbase.py 2012-07-03 08:07:22 +0000 |
| 3668 | @@ -131,7 +131,7 @@ |
| 3669 | try: |
| 3670 | desired_component = getUtility(IComponentSet)[ |
| 3671 | self.options.component] |
| 3672 | - except NotFoundError, err: |
| 3673 | + except NotFoundError as err: |
| 3674 | raise SoyuzScriptError(err) |
| 3675 | |
| 3676 | if currently_published.component != desired_component: |
| 3677 | @@ -253,7 +253,7 @@ |
| 3678 | try: |
| 3679 | self.setupLocation() |
| 3680 | self.mainTask() |
| 3681 | - except SoyuzScriptError, err: |
| 3682 | + except SoyuzScriptError as err: |
| 3683 | raise LaunchpadScriptFailure(err) |
| 3684 | |
| 3685 | self.finishProcedure() |
| 3686 | |
| 3687 | === modified file 'lib/lp/soyuz/scripts/gina/packages.py' |
| 3688 | --- lib/lp/soyuz/scripts/gina/packages.py 2012-06-19 22:53:13 +0000 |
| 3689 | +++ lib/lp/soyuz/scripts/gina/packages.py 2012-07-03 08:07:22 +0000 |
| 3690 | @@ -105,7 +105,7 @@ |
| 3691 | component, archive_root) |
| 3692 | try: |
| 3693 | extract_dpkg_source(dsc_path, ".", vendor=distro_name) |
| 3694 | - except DpkgSourceError, e: |
| 3695 | + except DpkgSourceError as e: |
| 3696 | raise ExecutionError("Error %d unpacking source" % e.result) |
| 3697 | |
| 3698 | version = re.sub("^\d+:", "", version) |
| 3699 | |
| 3700 | === modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py' |
| 3701 | --- lib/lp/soyuz/scripts/initialize_distroseries.py 2012-04-23 01:06:55 +0000 |
| 3702 | +++ lib/lp/soyuz/scripts/initialize_distroseries.py 2012-07-03 08:07:22 +0000 |
| 3703 | @@ -569,7 +569,7 @@ |
| 3704 | list(self.distroseries.architectures)) |
| 3705 | rebuilds.extend(builds) |
| 3706 | self._rescore_rebuilds(rebuilds) |
| 3707 | - except CannotCopy, error: |
| 3708 | + except CannotCopy as error: |
| 3709 | raise InitializationError(error) |
| 3710 | |
| 3711 | def _rescore_rebuilds(self, builds): |
| 3712 | |
| 3713 | === modified file 'lib/lp/soyuz/scripts/packagecopier.py' |
| 3714 | --- lib/lp/soyuz/scripts/packagecopier.py 2012-06-30 23:36:12 +0000 |
| 3715 | +++ lib/lp/soyuz/scripts/packagecopier.py 2012-07-03 08:07:22 +0000 |
| 3716 | @@ -647,7 +647,7 @@ |
| 3717 | try: |
| 3718 | copy_checker.checkCopy( |
| 3719 | source, destination_series, pocket, person, check_permissions) |
| 3720 | - except CannotCopy, reason: |
| 3721 | + except CannotCopy as reason: |
| 3722 | errors.append("%s (%s)" % (source.displayname, reason)) |
| 3723 | continue |
| 3724 | |
| 3725 | @@ -1065,7 +1065,7 @@ |
| 3726 | self.options.include_binaries, allow_delayed_copies=False, |
| 3727 | check_permissions=False, unembargo=self.options.unembargo, |
| 3728 | logger=self.logger) |
| 3729 | - except CannotCopy, error: |
| 3730 | + except CannotCopy as error: |
| 3731 | self.logger.error(str(error)) |
| 3732 | return [] |
| 3733 | |
| 3734 | |
| 3735 | === modified file 'lib/lp/soyuz/scripts/publishdistro.py' |
| 3736 | --- lib/lp/soyuz/scripts/publishdistro.py 2011-08-08 07:31:08 +0000 |
| 3737 | +++ lib/lp/soyuz/scripts/publishdistro.py 2012-07-03 08:07:22 +0000 |
| 3738 | @@ -220,7 +220,7 @@ |
| 3739 | """ |
| 3740 | try: |
| 3741 | series, pocket = distribution.getDistroSeriesAndPocket(suite) |
| 3742 | - except NotFoundError, e: |
| 3743 | + except NotFoundError as e: |
| 3744 | raise OptionValueError(e) |
| 3745 | return series.name, pocket |
| 3746 | |
| 3747 | |
| 3748 | === modified file 'lib/lp/soyuz/scripts/querydistro.py' |
| 3749 | --- lib/lp/soyuz/scripts/querydistro.py 2012-06-20 01:19:03 +0000 |
| 3750 | +++ lib/lp/soyuz/scripts/querydistro.py 2012-07-03 08:07:22 +0000 |
| 3751 | @@ -58,7 +58,7 @@ |
| 3752 | self.location = build_package_location( |
| 3753 | distribution_name=self.options.distribution_name, |
| 3754 | suite=self.options.suite) |
| 3755 | - except PackageLocationError, err: |
| 3756 | + except PackageLocationError as err: |
| 3757 | raise LaunchpadScriptFailure(err) |
| 3758 | |
| 3759 | def defaultPresenter(self, result): |
| 3760 | |
| 3761 | === modified file 'lib/lp/soyuz/scripts/queue.py' |
| 3762 | --- lib/lp/soyuz/scripts/queue.py 2012-02-10 10:50:03 +0000 |
| 3763 | +++ lib/lp/soyuz/scripts/queue.py 2012-07-03 08:07:22 +0000 |
| 3764 | @@ -167,7 +167,7 @@ |
| 3765 | # retrieve PackageUpload item by id |
| 3766 | try: |
| 3767 | item = getUtility(IPackageUploadSet).get(int(term)) |
| 3768 | - except NotFoundError, info: |
| 3769 | + except NotFoundError as info: |
| 3770 | raise QueueActionError('Queue Item not found: %s' % info) |
| 3771 | |
| 3772 | if item.status != self.queue: |
| 3773 | @@ -429,7 +429,7 @@ |
| 3774 | # do not overwrite files on disk (bug # 62976) |
| 3775 | try: |
| 3776 | existing_file = open(libfile.filename, "r") |
| 3777 | - except IOError, e: |
| 3778 | + except IOError as e: |
| 3779 | if not e.errno == errno.ENOENT: |
| 3780 | raise |
| 3781 | # File does not already exist, so read file from librarian |
| 3782 | @@ -477,7 +477,7 @@ |
| 3783 | try: |
| 3784 | queue_item.rejectFromQueue( |
| 3785 | logger=self.log, dry_run=self.no_mail) |
| 3786 | - except QueueInconsistentStateError, info: |
| 3787 | + except QueueInconsistentStateError as info: |
| 3788 | self.display('** %s could not be rejected due %s' |
| 3789 | % (queue_item.displayname, info)) |
| 3790 | |
| 3791 | @@ -502,7 +502,7 @@ |
| 3792 | try: |
| 3793 | queue_item.acceptFromQueue( |
| 3794 | logger=self.log, dry_run=self.no_mail) |
| 3795 | - except QueueInconsistentStateError, info: |
| 3796 | + except QueueInconsistentStateError as info: |
| 3797 | self.display('** %s could not be accepted due to %s' |
| 3798 | % (queue_item.displayname, info)) |
| 3799 | continue |
| 3800 | @@ -586,7 +586,7 @@ |
| 3801 | component = getUtility(IComponentSet)[self.component_name] |
| 3802 | if self.section_name: |
| 3803 | section = getUtility(ISectionSet)[self.section_name] |
| 3804 | - except NotFoundError, info: |
| 3805 | + except NotFoundError as info: |
| 3806 | raise QueueActionError('Not Found: %s' % info) |
| 3807 | |
| 3808 | for queue_item in self.items: |
| 3809 | @@ -620,7 +620,7 @@ |
| 3810 | section = getUtility(ISectionSet)[self.section_name] |
| 3811 | if self.priority_name: |
| 3812 | priority = name_priority_map[self.priority_name] |
| 3813 | - except (NotFoundError, KeyError), info: |
| 3814 | + except (NotFoundError, KeyError) as info: |
| 3815 | raise QueueActionError('Not Found: %s' % info) |
| 3816 | |
| 3817 | overridden = [] |
| 3818 | @@ -731,7 +731,7 @@ |
| 3819 | log=self.log) |
| 3820 | queue_action.initialize() |
| 3821 | queue_action.run() |
| 3822 | - except QueueActionError, info: |
| 3823 | + except QueueActionError as info: |
| 3824 | raise CommandRunnerError(info) |
| 3825 | |
| 3826 | return queue_action |
| 3827 | |
| 3828 | === modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py' |
| 3829 | --- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2012-04-23 17:54:25 +0000 |
| 3830 | +++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2012-07-03 08:07:22 +0000 |
| 3831 | @@ -945,7 +945,7 @@ |
| 3832 | switch_dbuser(user) |
| 3833 | try: |
| 3834 | create_job(derived, packages[user], parent) |
| 3835 | - except ProgrammingError, e: |
| 3836 | + except ProgrammingError as e: |
| 3837 | self.assertTrue( |
| 3838 | False, |
| 3839 | "Database role %s was unable to create a job. " |
| 3840 | |
| 3841 | === modified file 'lib/lp/testing/browser.py' |
| 3842 | --- lib/lp/testing/browser.py 2011-12-22 05:09:10 +0000 |
| 3843 | +++ lib/lp/testing/browser.py 2012-07-03 08:07:22 +0000 |
| 3844 | @@ -118,7 +118,7 @@ |
| 3845 | try: |
| 3846 | self.mech_browser.submit(id=control.id, name=control.name, |
| 3847 | label=label, coord=coord) |
| 3848 | - except Exception, e: |
| 3849 | + except Exception as e: |
| 3850 | fix_exception_name(e) |
| 3851 | raise |
| 3852 | self._stop_timer() |
| 3853 | |
| 3854 | === modified file 'lib/lp/testing/keyserver/web.py' |
| 3855 | --- lib/lp/testing/keyserver/web.py 2011-12-09 00:20:44 +0000 |
| 3856 | +++ lib/lp/testing/keyserver/web.py 2012-07-03 08:07:22 +0000 |
| 3857 | @@ -198,7 +198,7 @@ |
| 3858 | try: |
| 3859 | key = gpghandler.importPublicKey(keytext) |
| 3860 | except (GPGKeyNotFoundError, SecretGPGKeyImportDetected, |
| 3861 | - MoreThanOneGPGKeyFound), err: |
| 3862 | + MoreThanOneGPGKeyFound) as err: |
| 3863 | return SUBMIT_KEY_PAGE % {'banner': str(err)} |
| 3864 | |
| 3865 | filename = '0x%s.get' % key.fingerprint |
| 3866 | |
| 3867 | === modified file 'lib/lp/testing/layers.py' |
| 3868 | --- lib/lp/testing/layers.py 2012-07-02 04:21:44 +0000 |
| 3869 | +++ lib/lp/testing/layers.py 2012-07-03 08:07:22 +0000 |
| 3870 | @@ -248,7 +248,7 @@ |
| 3871 | while True: |
| 3872 | try: |
| 3873 | os.waitpid(-1, os.WNOHANG) |
| 3874 | - except OSError, error: |
| 3875 | + except OSError as error: |
| 3876 | if error.errno != errno.ECHILD: |
| 3877 | raise |
| 3878 | break |
| 3879 | @@ -909,7 +909,7 @@ |
| 3880 | try: |
| 3881 | f = urlopen(config.librarian.download_url) |
| 3882 | f.read() |
| 3883 | - except Exception, e: |
| 3884 | + except Exception as e: |
| 3885 | raise LayerIsolationError( |
| 3886 | "Librarian has been killed or has hung." |
| 3887 | "Tests should use LibrarianLayer.hide() and " |
| 3888 | @@ -1755,7 +1755,7 @@ |
| 3889 | """ |
| 3890 | try: |
| 3891 | os.kill(cls.appserver.pid, sig) |
| 3892 | - except OSError, error: |
| 3893 | + except OSError as error: |
| 3894 | if error.errno == errno.ESRCH: |
| 3895 | # The child process doesn't exist. Maybe it went away by the |
| 3896 | # time we got here. |
| 3897 | @@ -1818,7 +1818,7 @@ |
| 3898 | # Don't worry if the process no longer exists. |
| 3899 | try: |
| 3900 | os.kill(pid, signal.SIGTERM) |
| 3901 | - except OSError, error: |
| 3902 | + except OSError as error: |
| 3903 | if error.errno != errno.ESRCH: |
| 3904 | raise |
| 3905 | pidfile.remove_pidfile('launchpad', cls.appserver_config) |
| 3906 | @@ -1850,7 +1850,7 @@ |
| 3907 | try: |
| 3908 | connection = urlopen(root_url) |
| 3909 | connection.read() |
| 3910 | - except IOError, error: |
| 3911 | + except IOError as error: |
| 3912 | # We are interested in a wrapped socket.error. |
| 3913 | # urlopen() really sucks here. |
| 3914 | if len(error.args) <= 1: |
| 3915 | |
| 3916 | === modified file 'lib/lp/testing/matchers.py' |
| 3917 | --- lib/lp/testing/matchers.py 2011-12-24 17:49:30 +0000 |
| 3918 | +++ lib/lp/testing/matchers.py 2012-07-03 08:07:22 +0000 |
| 3919 | @@ -156,7 +156,7 @@ |
| 3920 | if not verifyObject(self.interface, matchee): |
| 3921 | passed = False |
| 3922 | except (BrokenImplementation, BrokenMethodImplementation, |
| 3923 | - DoesNotImplement), e: |
| 3924 | + DoesNotImplement) as e: |
| 3925 | passed = False |
| 3926 | extra = str(e) |
| 3927 | if not passed: |
| 3928 | |
| 3929 | === modified file 'lib/lp/testing/pgsql.py' |
| 3930 | --- lib/lp/testing/pgsql.py 2011-12-30 06:14:56 +0000 |
| 3931 | +++ lib/lp/testing/pgsql.py 2012-07-03 08:07:22 +0000 |
| 3932 | @@ -338,7 +338,7 @@ |
| 3933 | "create db in %0.2fs\n" % ( |
| 3934 | time.time() - _start)) |
| 3935 | break |
| 3936 | - except psycopg2.DatabaseError, x: |
| 3937 | + except psycopg2.DatabaseError as x: |
| 3938 | if counter == attempts - 1: |
| 3939 | raise |
| 3940 | x = str(x) |
| 3941 | @@ -403,7 +403,7 @@ |
| 3942 | for i in range(0, attempts): |
| 3943 | try: |
| 3944 | con = self.superuser_connection(self.template) |
| 3945 | - except psycopg2.OperationalError, x: |
| 3946 | + except psycopg2.OperationalError as x: |
| 3947 | if 'does not exist' in str(x): |
| 3948 | return |
| 3949 | raise |
| 3950 | @@ -428,7 +428,7 @@ |
| 3951 | try: |
| 3952 | cur = con.cursor() |
| 3953 | cur.execute('DROP DATABASE %s' % self.dbname) |
| 3954 | - except psycopg2.DatabaseError, x: |
| 3955 | + except psycopg2.DatabaseError as x: |
| 3956 | if i == attempts - 1: |
| 3957 | # Too many failures - raise an exception |
| 3958 | raise |
| 3959 | |
| 3960 | === modified file 'lib/lp/testing/tests/test_matchers.py' |
| 3961 | --- lib/lp/testing/tests/test_matchers.py 2012-01-01 02:58:52 +0000 |
| 3962 | +++ lib/lp/testing/tests/test_matchers.py 2012-07-03 08:07:22 +0000 |
| 3963 | @@ -137,7 +137,7 @@ |
| 3964 | try: |
| 3965 | verifyObject(ITestInterface, obj) |
| 3966 | self.assert_("verifyObject did not raise an exception.") |
| 3967 | - except BrokenImplementation, e: |
| 3968 | + except BrokenImplementation as e: |
| 3969 | extra = str(e) |
| 3970 | self.assertEqual(extra, mismatch.extra) |
| 3971 | |
| 3972 | |
| 3973 | === modified file 'lib/lp/translations/browser/language.py' |
| 3974 | --- lib/lp/translations/browser/language.py 2012-01-01 02:58:52 +0000 |
| 3975 | +++ lib/lp/translations/browser/language.py 2012-07-03 08:07:22 +0000 |
| 3976 | @@ -327,7 +327,7 @@ |
| 3977 | """Validate plural expression and number of plural forms.""" |
| 3978 | try: |
| 3979 | make_friendly_plural_forms(pluralexpression, pluralforms) |
| 3980 | - except BadPluralExpression, e: |
| 3981 | + except BadPluralExpression as e: |
| 3982 | self.setFieldError('pluralexpression', str(e)) |
| 3983 | |
| 3984 | def validate(self, data): |
| 3985 | |
| 3986 | === modified file 'lib/lp/translations/browser/tests/distroseries-views.txt' |
| 3987 | --- lib/lp/translations/browser/tests/distroseries-views.txt 2012-04-10 14:01:17 +0000 |
| 3988 | +++ lib/lp/translations/browser/tests/distroseries-views.txt 2012-07-03 08:07:22 +0000 |
| 3989 | @@ -40,7 +40,7 @@ |
| 3990 | ... |
| 3991 | ... try: |
| 3992 | ... view.checkTranslationsViewable() |
| 3993 | - ... except TranslationUnavailable, message: |
| 3994 | + ... except TranslationUnavailable as message: |
| 3995 | ... return unicode(message) |
| 3996 | ... return None |
| 3997 | |
| 3998 | |
| 3999 | === modified file 'lib/lp/translations/browser/translationmessage.py' |
| 4000 | --- lib/lp/translations/browser/translationmessage.py 2012-02-17 07:43:40 +0000 |
| 4001 | +++ lib/lp/translations/browser/translationmessage.py 2012-07-03 08:07:22 +0000 |
| 4002 | @@ -454,7 +454,7 @@ |
| 4003 | """ |
| 4004 | try: |
| 4005 | self._storeTranslations(potmsgset) |
| 4006 | - except GettextValidationError, e: |
| 4007 | + except GettextValidationError as e: |
| 4008 | return unicode(e) |
| 4009 | except TranslationConflict: |
| 4010 | # The translations are demoted to suggestions, but they may |
| 4011 | |
| 4012 | === modified file 'lib/lp/translations/model/pofile.py' |
| 4013 | --- lib/lp/translations/model/pofile.py 2012-02-15 21:14:05 +0000 |
| 4014 | +++ lib/lp/translations/model/pofile.py 2012-07-03 08:07:22 +0000 |
| 4015 | @@ -1044,7 +1044,7 @@ |
| 4016 | entry_to_import.setErrorOutput( |
| 4017 | "File was not exported from Launchpad.") |
| 4018 | except (MixedNewlineMarkersError, TranslationFormatSyntaxError, |
| 4019 | - TranslationFormatInvalidInputError, UnicodeDecodeError), ( |
| 4020 | + TranslationFormatInvalidInputError, UnicodeDecodeError) as ( |
| 4021 | exception): |
| 4022 | # The import failed with a format error. We log it and select the |
| 4023 | # email template. |
| 4024 | @@ -1059,7 +1059,7 @@ |
| 4025 | error_text = str(exception) |
| 4026 | entry_to_import.setErrorOutput(error_text) |
| 4027 | needs_notification_for_imported = True |
| 4028 | - except OutdatedTranslationError, exception: |
| 4029 | + except OutdatedTranslationError as exception: |
| 4030 | # The attached file is older than the last imported one, we ignore |
| 4031 | # it. We also log this problem and select the email template. |
| 4032 | if logger: |
| 4033 | |
| 4034 | === modified file 'lib/lp/translations/model/potemplate.py' |
| 4035 | --- lib/lp/translations/model/potemplate.py 2011-12-30 06:14:56 +0000 |
| 4036 | +++ lib/lp/translations/model/potemplate.py 2012-07-03 08:07:22 +0000 |
| 4037 | @@ -941,7 +941,7 @@ |
| 4038 | errors, warnings = translation_importer.importFile( |
| 4039 | entry_to_import, logger) |
| 4040 | except (MixedNewlineMarkersError, TranslationFormatSyntaxError, |
| 4041 | - TranslationFormatInvalidInputError, UnicodeDecodeError), ( |
| 4042 | + TranslationFormatInvalidInputError, UnicodeDecodeError) as ( |
| 4043 | exception): |
| 4044 | if logger: |
| 4045 | logger.info( |
| 4046 | @@ -1005,7 +1005,7 @@ |
| 4047 | if txn is not None: |
| 4048 | txn.commit() |
| 4049 | txn.begin() |
| 4050 | - except TransactionRollbackError, error: |
| 4051 | + except TransactionRollbackError as error: |
| 4052 | if txn is not None: |
| 4053 | txn.abort() |
| 4054 | txn.begin() |
| 4055 | |
| 4056 | === modified file 'lib/lp/translations/model/translationtemplatesbuildjob.py' |
| 4057 | --- lib/lp/translations/model/translationtemplatesbuildjob.py 2012-01-02 11:21:14 +0000 |
| 4058 | +++ lib/lp/translations/model/translationtemplatesbuildjob.py 2012-07-03 08:07:22 +0000 |
| 4059 | @@ -209,7 +209,7 @@ |
| 4060 | "Requesting templates build for branch %s.", |
| 4061 | branch.unique_name) |
| 4062 | cls.create(branch) |
| 4063 | - except Exception, e: |
| 4064 | + except Exception as e: |
| 4065 | logger.error(e) |
| 4066 | raise |
| 4067 | |
| 4068 | |
| 4069 | === modified file 'lib/lp/translations/scripts/copy_distroseries_translations.py' |
| 4070 | --- lib/lp/translations/scripts/copy_distroseries_translations.py 2012-06-29 14:36:44 +0000 |
| 4071 | +++ lib/lp/translations/scripts/copy_distroseries_translations.py 2012-07-03 08:07:22 +0000 |
| 4072 | @@ -98,7 +98,7 @@ |
| 4073 | finally: |
| 4074 | try: |
| 4075 | statekeeper.restore() |
| 4076 | - except Warning, message: |
| 4077 | + except Warning as message: |
| 4078 | logger.warning(message) |
| 4079 | except: |
| 4080 | logger.warning( |
| 4081 | |
| 4082 | === modified file 'lib/lp/translations/scripts/gettext_check_messages.py' |
| 4083 | --- lib/lp/translations/scripts/gettext_check_messages.py 2010-12-02 16:13:51 +0000 |
| 4084 | +++ lib/lp/translations/scripts/gettext_check_messages.py 2012-07-03 08:07:22 +0000 |
| 4085 | @@ -100,7 +100,7 @@ |
| 4086 | validate_translation( |
| 4087 | potmsgset.singular_text, potmsgset.plural_text, |
| 4088 | msgstrs, potmsgset.flags) |
| 4089 | - except GettextValidationError, error: |
| 4090 | + except GettextValidationError as error: |
| 4091 | self._error_count += 1 |
| 4092 | return unicode(error) |
| 4093 | |
| 4094 | |
| 4095 | === modified file 'lib/lp/translations/scripts/language_pack.py' |
| 4096 | --- lib/lp/translations/scripts/language_pack.py 2011-12-30 06:14:56 +0000 |
| 4097 | +++ lib/lp/translations/scripts/language_pack.py 2012-07-03 08:07:22 +0000 |
| 4098 | @@ -281,7 +281,7 @@ |
| 4099 | size=size, |
| 4100 | file=filehandle, |
| 4101 | contentType='application/x-gtar') |
| 4102 | - except UploadFailed, e: |
| 4103 | + except UploadFailed as e: |
| 4104 | logger.error('Uploading to the Librarian failed: %s', e) |
| 4105 | return None |
| 4106 | except: |
| 4107 | |
| 4108 | === modified file 'lib/lp/translations/scripts/po_import.py' |
| 4109 | --- lib/lp/translations/scripts/po_import.py 2012-01-01 02:58:52 +0000 |
| 4110 | +++ lib/lp/translations/scripts/po_import.py 2012-07-03 08:07:22 +0000 |
| 4111 | @@ -191,10 +191,10 @@ |
| 4112 | self.txn.commit() |
| 4113 | except KeyboardInterrupt: |
| 4114 | raise |
| 4115 | - except (AssertionError, SystemError), e: |
| 4116 | + except (AssertionError, SystemError) as e: |
| 4117 | self._registerFailure(entry, e, abort=True) |
| 4118 | raise |
| 4119 | - except Exception, e: |
| 4120 | + except Exception as e: |
| 4121 | if self.txn: |
| 4122 | self.txn.abort() |
| 4123 | self._registerFailure(entry, e, traceback=True) |
| 4124 | |
| 4125 | === modified file 'lib/lp/translations/scripts/validate_translations_file.py' |
| 4126 | --- lib/lp/translations/scripts/validate_translations_file.py 2011-12-21 20:23:01 +0000 |
| 4127 | +++ lib/lp/translations/scripts/validate_translations_file.py 2012-07-03 08:07:22 +0000 |
| 4128 | @@ -116,7 +116,7 @@ |
| 4129 | raise |
| 4130 | except UnknownFileType: |
| 4131 | raise |
| 4132 | - except Exception, e: |
| 4133 | + except Exception as e: |
| 4134 | self.logger.warn("Failure in '%s': %s" % (filename, e)) |
| 4135 | return False |
| 4136 | |
| 4137 | |
| 4138 | === modified file 'lib/lp/translations/scripts/verify_pofile_stats.py' |
| 4139 | --- lib/lp/translations/scripts/verify_pofile_stats.py 2012-01-01 02:58:52 +0000 |
| 4140 | +++ lib/lp/translations/scripts/verify_pofile_stats.py 2012-07-03 08:07:22 +0000 |
| 4141 | @@ -75,7 +75,7 @@ |
| 4142 | self._verify(pofile) |
| 4143 | except (KeyboardInterrupt, SystemExit): |
| 4144 | raise |
| 4145 | - except Exception, error: |
| 4146 | + except Exception as error: |
| 4147 | # Verification failed for this POFile. Don't bail out: if |
| 4148 | # there's a pattern of failure, we'll want to report that and |
| 4149 | # not just the first problem we encounter. |
| 4150 | |
| 4151 | === modified file 'lib/lp/translations/stories/translationgroups/xx-link-to-documentation.txt' |
| 4152 | --- lib/lp/translations/stories/translationgroups/xx-link-to-documentation.txt 2012-06-16 21:13:24 +0000 |
| 4153 | +++ lib/lp/translations/stories/translationgroups/xx-link-to-documentation.txt 2012-07-03 08:07:22 +0000 |
| 4154 | @@ -70,7 +70,7 @@ |
| 4155 | ... test_browser.open( |
| 4156 | ... 'http://translations.launchpad.dev/' |
| 4157 | ... '+groups/testing-translation-team/eo/+admin') |
| 4158 | - ... except Unauthorized, e: |
| 4159 | + ... except Unauthorized as e: |
| 4160 | ... print e |
| 4161 | (...'launchpad.Admin') |
| 4162 | >>> test_browser.open( |
| 4163 | |
| 4164 | === modified file 'lib/lp/translations/tests/test_pottery_detect_intltool.py' |
| 4165 | --- lib/lp/translations/tests/test_pottery_detect_intltool.py 2011-12-21 19:25:05 +0000 |
| 4166 | +++ lib/lp/translations/tests/test_pottery_detect_intltool.py 2012-07-03 08:07:22 +0000 |
| 4167 | @@ -56,7 +56,7 @@ |
| 4168 | if directory != '': |
| 4169 | try: |
| 4170 | os.makedirs(directory) |
| 4171 | - except OSError, e: |
| 4172 | + except OSError as e: |
| 4173 | # Doesn't matter if it already exists. |
| 4174 | if e.errno != 17: |
| 4175 | raise |
| 4176 | |
| 4177 | === modified file 'lib/lp/translations/utilities/gettext_po_parser.py' |
| 4178 | --- lib/lp/translations/utilities/gettext_po_parser.py 2011-06-09 10:50:25 +0000 |
| 4179 | +++ lib/lp/translations/utilities/gettext_po_parser.py 2012-07-03 08:07:22 +0000 |
| 4180 | @@ -228,7 +228,7 @@ |
| 4181 | """Attempt to parse `date_string`, or return None if invalid.""" |
| 4182 | try: |
| 4183 | return zope_datetime.parseDatetimetz(date_string) |
| 4184 | - except (ValueError, zope_datetime.DateTimeError), exception: |
| 4185 | + except (ValueError, zope_datetime.DateTimeError) as exception: |
| 4186 | return None |
| 4187 | |
| 4188 | def _parseHeaderFields(self): |
| 4189 | @@ -478,7 +478,7 @@ |
| 4190 | # decode as many characters as we can: |
| 4191 | try: |
| 4192 | newchars, length = decode(self._pending_chars, 'strict') |
| 4193 | - except UnicodeDecodeError, exc: |
| 4194 | + except UnicodeDecodeError as exc: |
| 4195 | # XXX: James Henstridge 2006-03-16: |
| 4196 | # If the number of unconvertable chars is longer than a |
| 4197 | # multibyte sequence to be, the UnicodeDecodeError indicates |
| 4198 | @@ -619,7 +619,7 @@ |
| 4199 | header = POHeader(header_text, header_comment) |
| 4200 | self._translation_file.header = header |
| 4201 | self._translation_file.syntax_warnings += header.syntax_warnings |
| 4202 | - except TranslationFormatInvalidInputError, error: |
| 4203 | + except TranslationFormatInvalidInputError as error: |
| 4204 | if error.line_number is None: |
| 4205 | error.line_number = self._message_lineno |
| 4206 | raise |
| 4207 | |
| 4208 | === modified file 'lib/lp/translations/utilities/mozilla_xpi_importer.py' |
| 4209 | --- lib/lp/translations/utilities/mozilla_xpi_importer.py 2012-05-24 20:25:54 +0000 |
| 4210 | +++ lib/lp/translations/utilities/mozilla_xpi_importer.py 2012-07-03 08:07:22 +0000 |
| 4211 | @@ -229,7 +229,7 @@ |
| 4212 | try: |
| 4213 | string = line.encode('raw-unicode_escape') |
| 4214 | line = string.decode('unicode_escape') |
| 4215 | - except UnicodeDecodeError, exception: |
| 4216 | + except UnicodeDecodeError as exception: |
| 4217 | raise TranslationFormatInvalidInputError( |
| 4218 | filename=self.filename, line_number=line_num, |
| 4219 | message=str(exception)) |
| 4220 | |
| 4221 | === modified file 'lib/lp/translations/utilities/mozilla_zip.py' |
| 4222 | --- lib/lp/translations/utilities/mozilla_zip.py 2010-08-20 20:31:18 +0000 |
| 4223 | +++ lib/lp/translations/utilities/mozilla_zip.py 2012-07-03 08:07:22 +0000 |
| 4224 | @@ -53,7 +53,7 @@ |
| 4225 | self.manifest = manifest |
| 4226 | try: |
| 4227 | self.archive = ZipFile(archive, 'r') |
| 4228 | - except BadZipfile, exception: |
| 4229 | + except BadZipfile as exception: |
| 4230 | raise TranslationFormatInvalidInputError( |
| 4231 | filename=filename, message=str(exception)) |
| 4232 | |
| 4233 | |
| 4234 | === modified file 'lib/lp/translations/utilities/pluralforms.py' |
| 4235 | --- lib/lp/translations/utilities/pluralforms.py 2010-08-20 20:31:18 +0000 |
| 4236 | +++ lib/lp/translations/utilities/pluralforms.py 2012-07-03 08:07:22 +0000 |
| 4237 | @@ -74,7 +74,7 @@ |
| 4238 | |
| 4239 | try: |
| 4240 | function = gettext.c2py(expression) |
| 4241 | - except (ValueError, SyntaxError), e: |
| 4242 | + except (ValueError, SyntaxError) as e: |
| 4243 | raise BadPluralExpression(e.args[0]) |
| 4244 | |
| 4245 | return function |
| 4246 | |
| 4247 | === modified file 'lib/lp/translations/utilities/tests/test_gettext_po_parser.py' |
| 4248 | --- lib/lp/translations/utilities/tests/test_gettext_po_parser.py 2010-08-20 20:31:18 +0000 |
| 4249 | +++ lib/lp/translations/utilities/tests/test_gettext_po_parser.py 2012-07-03 08:07:22 +0000 |
| 4250 | @@ -36,7 +36,7 @@ |
| 4251 | self.assertTrue( |
| 4252 | False, |
| 4253 | "Importing an empty file succeeded; it should have failed.") |
| 4254 | - except TranslationFormatSyntaxError, exception: |
| 4255 | + except TranslationFormatSyntaxError as exception: |
| 4256 | message = exception.represent("Default error message!") |
| 4257 | |
| 4258 | self.assertEqual(message, "File contains no messages.") |
| 4259 | |
| 4260 | === modified file 'lib/lp/translations/utilities/tests/test_translation_message_data.py' |
| 4261 | --- lib/lp/translations/utilities/tests/test_translation_message_data.py 2011-08-12 11:37:08 +0000 |
| 4262 | +++ lib/lp/translations/utilities/tests/test_translation_message_data.py 2012-07-03 08:07:22 +0000 |
| 4263 | @@ -70,7 +70,7 @@ |
| 4264 | data.addTranslation(0, 'singular') |
| 4265 | try: |
| 4266 | data.addTranslation(0, 'ralugnis') |
| 4267 | - except TranslationFormatSyntaxError, error: |
| 4268 | + except TranslationFormatSyntaxError as error: |
| 4269 | self.assertEqual( |
| 4270 | error.represent("(Default text, should not be returned.)"), |
| 4271 | "Message has more than one translation for plural form 0.") |
| 4272 | |
| 4273 | === modified file 'lib/lp/translations/utilities/translation_import.py' |
| 4274 | --- lib/lp/translations/utilities/translation_import.py 2011-12-30 06:14:56 +0000 |
| 4275 | +++ lib/lp/translations/utilities/translation_import.py 2012-07-03 08:07:22 +0000 |
| 4276 | @@ -472,7 +472,7 @@ |
| 4277 | validate_translation( |
| 4278 | potmsgset.singular_text, potmsgset.plural_text, |
| 4279 | translations, potmsgset.flags) |
| 4280 | - except GettextValidationError, e: |
| 4281 | + except GettextValidationError as e: |
| 4282 | self._addUpdateError(message_data, potmsgset, unicode(e)) |
| 4283 | message.validation_status = ( |
| 4284 | TranslationValidationStatus.UNKNOWNERROR) |
| 4285 | |
| 4286 | === modified file 'lib/lp/translations/utilities/validate.py' |
| 4287 | --- lib/lp/translations/utilities/validate.py 2010-11-22 14:27:36 +0000 |
| 4288 | +++ lib/lp/translations/utilities/validate.py 2012-07-03 08:07:22 +0000 |
| 4289 | @@ -46,6 +46,6 @@ |
| 4290 | # Check the msg. |
| 4291 | try: |
| 4292 | msg.check_format() |
| 4293 | - except gettextpo.error, e: |
| 4294 | + except gettextpo.error as e: |
| 4295 | # Wrap gettextpo.error in GettextValidationError. |
| 4296 | raise GettextValidationError(unicode(e)) |
| 4297 | |
| 4298 | === modified file 'lib/lp/translations/utilities/xpi_header.py' |
| 4299 | --- lib/lp/translations/utilities/xpi_header.py 2010-08-20 20:31:18 +0000 |
| 4300 | +++ lib/lp/translations/utilities/xpi_header.py 2012-07-03 08:07:22 +0000 |
| 4301 | @@ -77,7 +77,7 @@ |
| 4302 | name, email = parseaddr(elem.text) |
| 4303 | if name != '' and '@' in email: |
| 4304 | last_name, last_email = name, email |
| 4305 | - except SyntaxError, exception: |
| 4306 | + except SyntaxError as exception: |
| 4307 | raise TranslationFormatSyntaxError( |
| 4308 | filename='install.rdf', line_number=exception.lineno, |
| 4309 | message=exception.msg) |
| 4310 | |
| 4311 | === modified file 'lib/lp/xmlrpc/helpers.py' |
| 4312 | --- lib/lp/xmlrpc/helpers.py 2010-08-20 20:31:18 +0000 |
| 4313 | +++ lib/lp/xmlrpc/helpers.py 2012-07-03 08:07:22 +0000 |
| 4314 | @@ -19,7 +19,7 @@ |
| 4315 | def decorated(*args, **kwargs): |
| 4316 | try: |
| 4317 | return function(*args, **kwargs) |
| 4318 | - except Fault, fault: |
| 4319 | + except Fault as fault: |
| 4320 | return fault |
| 4321 | |
| 4322 | return mergeFunctionMetadata(function, decorated) |
| 4323 | |
| 4324 | === modified file 'lib/lp_sitecustomize.py' |
| 4325 | --- lib/lp_sitecustomize.py 2012-04-12 11:38:44 +0000 |
| 4326 | +++ lib/lp_sitecustomize.py 2012-07-03 08:07:22 +0000 |
| 4327 | @@ -165,7 +165,7 @@ |
| 4328 | def wrapped_converter(v): |
| 4329 | try: |
| 4330 | return converter(v) |
| 4331 | - except ValueError, e: |
| 4332 | + except ValueError as e: |
| 4333 | # Mark the exception as not being OOPS-worthy. |
| 4334 | alsoProvides(e, IUnloggedException) |
| 4335 | raise |
| 4336 | |
| 4337 | === modified file 'scripts/ftpmaster-tools/buildd-mass-retry.py' |
| 4338 | --- scripts/ftpmaster-tools/buildd-mass-retry.py 2012-01-01 03:13:08 +0000 |
| 4339 | +++ scripts/ftpmaster-tools/buildd-mass-retry.py 2012-07-03 08:07:22 +0000 |
| 4340 | @@ -64,7 +64,7 @@ |
| 4341 | try: |
| 4342 | distribution = getUtility(IDistributionSet)[ |
| 4343 | self.options.distribution] |
| 4344 | - except NotFoundError, info: |
| 4345 | + except NotFoundError as info: |
| 4346 | raise LaunchpadScriptFailure("Distribution not found: %s" % info) |
| 4347 | |
| 4348 | try: |
| 4349 | @@ -74,7 +74,7 @@ |
| 4350 | else: |
| 4351 | series = distribution.currentseries |
| 4352 | pocket = PackagePublishingPocket.RELEASE |
| 4353 | - except NotFoundError, info: |
| 4354 | + except NotFoundError as info: |
| 4355 | raise LaunchpadScriptFailure("Suite not found: %s" % info) |
| 4356 | |
| 4357 | # store distroseries as the current IHasBuildRecord provider |
| 4358 | @@ -83,7 +83,7 @@ |
| 4359 | if self.options.architecture: |
| 4360 | try: |
| 4361 | dar = series[self.options.architecture] |
| 4362 | - except NotFoundError, info: |
| 4363 | + except NotFoundError as info: |
| 4364 | raise LaunchpadScriptFailure(info) |
| 4365 | |
| 4366 | # store distroarchseries as the current IHasBuildRecord provider |
| 4367 | |
| 4368 | === modified file 'scripts/ftpmaster-tools/queue' |
| 4369 | --- scripts/ftpmaster-tools/queue 2012-01-01 03:13:08 +0000 |
| 4370 | +++ scripts/ftpmaster-tools/queue 2012-07-03 08:07:22 +0000 |
| 4371 | @@ -108,7 +108,7 @@ |
| 4372 | for single_args in args_list: |
| 4373 | try: |
| 4374 | cmd_runner.execute(single_args, self.options.exact_match) |
| 4375 | - except CommandRunnerError, info: |
| 4376 | + except CommandRunnerError as info: |
| 4377 | print (info) |
| 4378 | if self.options.ignore_errors: |
| 4379 | continue |
| 4380 | |
| 4381 | === modified file 'scripts/script-monitor-nagios.py' |
| 4382 | --- scripts/script-monitor-nagios.py 2011-12-30 06:47:17 +0000 |
| 4383 | +++ scripts/script-monitor-nagios.py 2012-07-03 08:07:22 +0000 |
| 4384 | @@ -102,7 +102,7 @@ |
| 4385 | # Construct our return message |
| 4386 | print "All scripts ran as expected" |
| 4387 | return 0 |
| 4388 | - except Exception, e: |
| 4389 | + except Exception as e: |
| 4390 | # Squeeze the exception type and stringification of the exception |
| 4391 | # value on to one line. |
| 4392 | print "Unhandled exception: %s %r" % (e.__class__.__name__, str(e)) |
| 4393 | |
| 4394 | === modified file 'scripts/stop-loggerhead.py' |
| 4395 | --- scripts/stop-loggerhead.py 2012-06-27 13:57:04 +0000 |
| 4396 | +++ scripts/stop-loggerhead.py 2012-07-03 08:07:22 +0000 |
| 4397 | @@ -18,7 +18,7 @@ |
| 4398 | |
| 4399 | try: |
| 4400 | f = open(pidfile, 'r') |
| 4401 | -except IOError, e: |
| 4402 | +except IOError as e: |
| 4403 | print 'No pid file found.' |
| 4404 | sys.exit(1) |
| 4405 | |
| 4406 | @@ -26,7 +26,7 @@ |
| 4407 | |
| 4408 | try: |
| 4409 | os.kill(pid, 0) |
| 4410 | -except OSError, e: |
| 4411 | +except OSError as e: |
| 4412 | print 'Stale pid file; server is not running.' |
| 4413 | sys.exit(1) |
| 4414 | |
| 4415 | |
| 4416 | === modified file 'test_on_merge.py' |
| 4417 | --- test_on_merge.py 2012-01-01 03:20:03 +0000 |
| 4418 | +++ test_on_merge.py 2012-07-03 08:07:22 +0000 |
| 4419 | @@ -81,7 +81,7 @@ |
| 4420 | cur = con.cursor() |
| 4421 | try: |
| 4422 | cur.execute('drop database launchpad_ftest_template') |
| 4423 | - except psycopg2.ProgrammingError, x: |
| 4424 | + except psycopg2.ProgrammingError as x: |
| 4425 | if 'does not exist' not in str(x): |
| 4426 | raise |
| 4427 | |
| 4428 | @@ -196,7 +196,7 @@ |
| 4429 | try: |
| 4430 | rlist, wlist, xlist = select.select(open_readers, [], [], TIMEOUT) |
| 4431 | break |
| 4432 | - except select.error, e: |
| 4433 | + except select.error as e: |
| 4434 | # nb: select.error doesn't expose a named 'errno' attribute, |
| 4435 | # at least in python 2.6.5; see |
| 4436 | # <http://mail.python.org/pipermail/python-dev/2000-October/009671.html> |
| 4437 | @@ -273,7 +273,7 @@ |
| 4438 | # Give the processes some time to shut down. |
| 4439 | time.sleep(3) |
| 4440 | |
| 4441 | - except OSError, exc: |
| 4442 | + except OSError as exc: |
| 4443 | if exc.errno == errno.ESRCH: |
| 4444 | # We tried to call os.killpg() and found the group to be empty. |
| 4445 | pass |
| 4446 | |
| 4447 | === modified file 'utilities/check-configs.py' |
| 4448 | --- utilities/check-configs.py 2012-01-01 03:10:25 +0000 |
| 4449 | +++ utilities/check-configs.py 2012-07-03 08:07:22 +0000 |
| 4450 | @@ -77,7 +77,7 @@ |
| 4451 | try: |
| 4452 | root, handlers = ZConfig.loadConfig( |
| 4453 | zconfig_schema, config, arguments) |
| 4454 | - except ZConfig.ConfigurationSyntaxError, error: |
| 4455 | + except ZConfig.ConfigurationSyntaxError as error: |
| 4456 | if options.verbosity > 2: |
| 4457 | traceback.print_exc() |
| 4458 | elif options.verbosity > 1: |
| 4459 | @@ -90,7 +90,7 @@ |
| 4460 | lazr_config = lazr_schema.load(config) |
| 4461 | try: |
| 4462 | lazr_config.validate() |
| 4463 | - except ConfigErrors, error: |
| 4464 | + except ConfigErrors as error: |
| 4465 | if options.verbosity > 2: |
| 4466 | messages = '\n'.join([str(er) for er in error.errors]) |
| 4467 | print messages |
| 4468 | |
| 4469 | === modified file 'utilities/check-content-interfaces.py' |
| 4470 | --- utilities/check-content-interfaces.py 2012-01-01 03:10:25 +0000 |
| 4471 | +++ utilities/check-content-interfaces.py 2012-07-03 08:07:22 +0000 |
| 4472 | @@ -62,11 +62,11 @@ |
| 4473 | try: |
| 4474 | classes_checked += 1 |
| 4475 | result = verifyClass(interface, klass) |
| 4476 | - except BrokenImplementation, e: |
| 4477 | + except BrokenImplementation as e: |
| 4478 | classes_with_failures += 1 |
| 4479 | print "%s fails to implement %s: missing attribute %s" % ( |
| 4480 | class_name, interface_name, e.name) |
| 4481 | - except BrokenMethodImplementation, e: |
| 4482 | + except BrokenMethodImplementation as e: |
| 4483 | classes_with_failures += 1 |
| 4484 | print "%s fails to implement %s: invalid method %s: %s" % ( |
| 4485 | class_name, interface_name, e.method, e.mess) |
| 4486 | |
| 4487 | === modified file 'utilities/community-contributions.py' |
| 4488 | --- utilities/community-contributions.py 2012-06-25 14:50:04 +0000 |
| 4489 | +++ utilities/community-contributions.py 2012-07-03 08:07:22 +0000 |
| 4490 | @@ -647,7 +647,7 @@ |
| 4491 | opts, args = getopt.getopt(sys.argv[1:], '?hq', |
| 4492 | ['help', 'usage', 'dry-run', 'draft-run', |
| 4493 | 'devel=', 'db-devel=']) |
| 4494 | - except getopt.GetoptError, e: |
| 4495 | + except getopt.GetoptError as e: |
| 4496 | sys.stderr.write("ERROR: " + str(e) + '\n\n') |
| 4497 | usage() |
| 4498 | sys.exit(1) |
| 4499 | |
| 4500 | === modified file 'utilities/findimports.py' |
| 4501 | --- utilities/findimports.py 2012-01-01 03:10:25 +0000 |
| 4502 | +++ utilities/findimports.py 2012-07-03 08:07:22 +0000 |
| 4503 | @@ -325,7 +325,7 @@ |
| 4504 | opts, args = getopt.getopt(argv[1:], 'duniah', |
| 4505 | ['dot', 'unused', 'all', 'names', 'imports', |
| 4506 | 'help']) |
| 4507 | - except getopt.error, e: |
| 4508 | + except getopt.error as e: |
| 4509 | print >> sys.stderr, "%s: %s" % (progname, e) |
| 4510 | print >> sys.stderr, "Try %s --help." % progname |
| 4511 | return 1 |
| 4512 | |
| 4513 | === modified file 'utilities/formatdoctest.py' |
| 4514 | --- utilities/formatdoctest.py 2012-01-01 03:10:25 +0000 |
| 4515 | +++ utilities/formatdoctest.py 2012-07-03 08:07:22 +0000 |
| 4516 | @@ -289,7 +289,7 @@ |
| 4517 | return |
| 4518 | try: |
| 4519 | tree = compiler.parse(code) |
| 4520 | - except (SyntaxError, IndentationError), exc: |
| 4521 | + except (SyntaxError, IndentationError) as exc: |
| 4522 | (lineno, offset_, line) = exc[1][1:] |
| 4523 | if line.endswith("\n"): |
| 4524 | line = line[:-1] |
| 4525 | |
| 4526 | === modified file 'utilities/link-external-sourcecode' |
| 4527 | --- utilities/link-external-sourcecode 2012-01-01 03:10:25 +0000 |
| 4528 | +++ utilities/link-external-sourcecode 2012-07-03 08:07:22 +0000 |
| 4529 | @@ -75,7 +75,7 @@ |
| 4530 | if islink(destination): |
| 4531 | unlink(destination) |
| 4532 | symlink(source, destination) |
| 4533 | - except OSError, error: |
| 4534 | + except OSError as error: |
| 4535 | stderr.write( |
| 4536 | ' Error linking %s: %s\n' % (basename(destination), error)) |
| 4537 | else: |
| 4538 | |
| 4539 | === modified file 'utilities/pgmassacre.py' |
| 4540 | --- utilities/pgmassacre.py 2012-01-01 03:10:25 +0000 |
| 4541 | +++ utilities/pgmassacre.py 2012-07-03 08:07:22 +0000 |
| 4542 | @@ -168,7 +168,7 @@ |
| 4543 | cur.execute(create_db_cmd) |
| 4544 | con.close() |
| 4545 | return 0 |
| 4546 | - except psycopg2.Error, exception: |
| 4547 | + except psycopg2.Error as exception: |
| 4548 | error_msg = str(exception) |
| 4549 | time.sleep(0.6) # Stats only updated every 500ms. |
| 4550 | now = time.time() |
| 4551 | |
| 4552 | === modified file 'utilities/tcpwatch/tcpwatch.py' |
| 4553 | --- utilities/tcpwatch/tcpwatch.py 2012-01-06 11:08:30 +0000 |
| 4554 | +++ utilities/tcpwatch/tcpwatch.py 2012-07-03 08:07:22 +0000 |
| 4555 | @@ -1361,7 +1361,7 @@ |
| 4556 | 'no-record-responses', |
| 4557 | 'no-record-errors', |
| 4558 | ]) |
| 4559 | - except getopt.GetoptError, msg: |
| 4560 | + except getopt.GetoptError as msg: |
| 4561 | usageError(msg) |
| 4562 | |
| 4563 | fwd_params = [] |

Given that a common failure in testing is to neglect error conditions, I
am concerned that any errors in this transformation will sneak through a
complete test run, and since reviewing this by hand is a non-starter, I
decided to write a program to parse the diff and whitelist the
transformations that I figured were totally safe and then manually
review all the remaining changes. These are my findings.
lib/lp/ bugs/externalbu gtracker/ bugzilla. py contained the only bad
transformation I could find.
- except (xmlrpclib. ResponseError, xml.parsers. expat.ExpatErro r): ResponseError as xml.parsers. expat.ExpatErro r:
+ except xmlrpclib.
There were some instances of except clauses that contained unnecessary
tupilization that was carried over in the transformation. It would be
nice to fix these too:
=== modified file 'lib/lp/ app/widgets/ tests/test_ datetime. py'
- except (ValueError,), e:
+ except (ValueError,) as e:
=== modified file 'lib/lp/ registry/ scripts/ distributionmir ror_prober. py' me,), e: tected, ), e: tected, ) as e:
- except (UnknownURLSche
+ except (UnknownURLScheme,) as e:
- except (InfiniteLoopDe
+ except (InfiniteLoopDe