Merge ~cjwatson/launchpad:py3-raise-except into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: e905016fc0d006cc1f22ddae73dc4b1575ae4aa3
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-raise-except
Merge into: launchpad:master
Diff against target: 142 lines (+13/-13)
7 files modified
database/schema/dbcontroller.py (+5/-5)
database/schema/full-update.py (+1/-1)
lib/lp/services/database/policy.py (+1/-1)
lib/lp/services/feeds/stories/xx-navigation.txt (+1/-1)
lib/lp/services/librarian/client.py (+1/-1)
lib/lp/translations/doc/poexport-queue.txt (+2/-2)
lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt (+2/-2)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Kristian Glass (community) Approve
Review via email: mp+373698@code.launchpad.net

Commit message

Use Python 3-style raise/except syntax

To post a comment you must log in.
Revision history for this message
Kristian Glass (doismellburning) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Self-approving to work around incorrect repository reviewer (which I've now fixed).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/dbcontroller.py b/database/schema/dbcontroller.py
2index b9a38a5..4b92935 100644
3--- a/database/schema/dbcontroller.py
4+++ b/database/schema/dbcontroller.py
5@@ -104,7 +104,7 @@ class DBController:
6 con = pg_connect(conn_str)
7 cur = con.cursor()
8 cur.execute('select pg_wal_replay_pause()')
9- except psycopg2.Error, x:
10+ except psycopg2.Error as x:
11 self.log.error(
12 'Unable to pause replication to %s (%s).'
13 % (name, str(x)))
14@@ -120,7 +120,7 @@ class DBController:
15 con = pg_connect(conn_str)
16 cur = con.cursor()
17 cur.execute('select pg_wal_replay_resume()')
18- except psycopg2.Error, x:
19+ except psycopg2.Error as x:
20 success = False
21 self.log.error(
22 'Failed to resume replication to %s (%s).'
23@@ -146,7 +146,7 @@ class DBController:
24 self.log.warn("Replication paused on %s. Resuming.", name)
25 cur.execute("SELECT pg_wal_replay_resume()")
26 wait_for_sync = True
27- except psycopg2.Error, x:
28+ except psycopg2.Error as x:
29 success = False
30 self.log.error(
31 "Failed to resume replication on %s (%s)", name, str(x))
32@@ -159,7 +159,7 @@ class DBController:
33 self.pgbouncer_cmd("DISABLE %s" % name, results=False)
34 self.pgbouncer_cmd("KILL %s" % name, results=False)
35 return True
36- except psycopg2.Error, x:
37+ except psycopg2.Error as x:
38 self.log.error("Unable to disable %s (%s)", name, str(x))
39 return False
40
41@@ -168,7 +168,7 @@ class DBController:
42 self.pgbouncer_cmd("RESUME %s" % name, results=False)
43 self.pgbouncer_cmd("ENABLE %s" % name, results=False)
44 return True
45- except psycopg2.Error, x:
46+ except psycopg2.Error as x:
47 self.log.error("Unable to enable %s (%s)", name, str(x))
48 return False
49
50diff --git a/database/schema/full-update.py b/database/schema/full-update.py
51index 1e48fbb..8c9b550 100755
52--- a/database/schema/full-update.py
53+++ b/database/schema/full-update.py
54@@ -105,7 +105,7 @@ def main():
55 # Master connection, not running in autocommit to allow us to
56 # rollback changes on failure.
57 master_con = psycopg2.connect(str(controller.master))
58- except Exception, x:
59+ except Exception as x:
60 log.fatal("Unable to open connection to master db (%s)", str(x))
61 return 94
62
63diff --git a/lib/lp/services/database/policy.py b/lib/lp/services/database/policy.py
64index 64213bc..066fdb3 100644
65--- a/lib/lp/services/database/policy.py
66+++ b/lib/lp/services/database/policy.py
67@@ -96,7 +96,7 @@ def get_connected_store(name, flavor):
68 # be put into reconnect state at the end of the transaction.
69 store._connection._event.emit('register-transaction')
70 raise
71- except psycopg2.OperationalError, exc:
72+ except psycopg2.OperationalError as exc:
73 # Per Bug #1025264, Storm emits psycopg2 errors when we
74 # want DisconnonnectionErrors, eg. attempting to open a
75 # new connection to a non-existent database.
76diff --git a/lib/lp/services/feeds/stories/xx-navigation.txt b/lib/lp/services/feeds/stories/xx-navigation.txt
77index ba45644..5ed27dd 100644
78--- a/lib/lp/services/feeds/stories/xx-navigation.txt
79+++ b/lib/lp/services/feeds/stories/xx-navigation.txt
80@@ -104,7 +104,7 @@ on feeds.launchpad.test and does not work on all the other vhosts.
81 ... print "Error accessing:", url
82 ... raise
83 ... else:
84- ... raise AssertionError, "Page should not exist: %s" % url
85+ ... raise AssertionError("Page should not exist: %s" % url)
86
87 These atom feeds should only exist on feeds.launchpad.test:
88
89diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py
90index 5a87bbd..edb1d72 100644
91--- a/lib/lp/services/librarian/client.py
92+++ b/lib/lp/services/librarian/client.py
93@@ -343,7 +343,7 @@ class FileDownloadClient:
94 # lines = results.split('\n')
95 # count, paths = lines[0], lines[1:]
96 # if int(count) != len(paths):
97- # raise DownloadFailed, 'Incomplete response'
98+ # raise DownloadFailed('Incomplete response')
99 # return paths
100
101 def _getAlias(self, aliasID, secure=False):
102diff --git a/lib/lp/translations/doc/poexport-queue.txt b/lib/lp/translations/doc/poexport-queue.txt
103index dab4576..58d9317 100644
104--- a/lib/lp/translations/doc/poexport-queue.txt
105+++ b/lib/lp/translations/doc/poexport-queue.txt
106@@ -37,7 +37,7 @@ exception handling so we can get the exception error:
107 Record the error.
108
109 >>> try:
110- ... raise AssertionError, "It's just an error for testing purposes"
111+ ... raise AssertionError("It's just an error for testing purposes")
112 ... except AssertionError:
113 ... result.addFailure()
114
115@@ -131,7 +131,7 @@ characters and can't be reported without triggering an error themselves.
116 Those are specially handled and reported.
117
118 >>> try:
119- ... raise AssertionError, b"Really nasty \xc3 non-ASCII error!"
120+ ... raise AssertionError(b"Really nasty \xc3 non-ASCII error!")
121 ... except AssertionError:
122 ... result.addFailure()
123 >>> result.notify()
124diff --git a/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt b/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt
125index d4e9a57..a15080f 100644
126--- a/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt
127+++ b/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt
128@@ -30,12 +30,12 @@ We are in read only mode, so there shouldn't be any textareas:
129 >>> main_content = find_tag_by_id(
130 ... browser.contents, 'messages_to_translate')
131 >>> for textarea in main_content.findAll('textarea'):
132- ... raise AssertionError, 'Found textarea:\n%s' % textarea
133+ ... raise AssertionError('Found textarea:\n%s' % textarea)
134
135 Neither any input widget:
136
137 >>> for input in main_content.findAll('input'):
138- ... raise AssertionError, 'Found input:\n%s' % input
139+ ... raise AssertionError('Found input:\n%s' % input)
140
141 As an anynoymous user you will have access to the download and details
142 pages for the pofile this message belongs to. The link to upload page

Subscribers

People subscribed via source and target branches

to status/vote changes: