Skip to content

Commit 463cb09

Browse files
committed
Py3: use 'except ... as' syntax.
1 parent e058ec9 commit 463cb09

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

example/appengine_oauth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def is_valid(self):
8686
request = self.get_oauth_request()
8787
client = self.get_client(request)
8888
params = self._server.verify_request(request, client, None)
89-
except Exception, e:
89+
except Exception as e:
9090
raise e
9191

9292
return client
@@ -95,7 +95,7 @@ class SampleHandler(OAuthHandler):
9595
def get(self):
9696
try:
9797
client = self.is_valid()
98-
except Exception, e:
98+
except Exception as e:
9999
self.error(500)
100100
self.response.out.write(e)
101101

example/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def do_GET(self):
131131
self.end_headers()
132132
# return the token
133133
self.wfile.write(token.to_string())
134-
except oauth.OAuthError, err:
134+
except oauth.OAuthError as err:
135135
self.send_oauth_error(err)
136136
return
137137

@@ -148,7 +148,7 @@ def do_GET(self):
148148
self.end_headers()
149149
# return the callback url (to show server has it)
150150
self.wfile.write(token.get_callback_url())
151-
except oauth.OAuthError, err:
151+
except oauth.OAuthError as err:
152152
self.send_oauth_error(err)
153153
return
154154

@@ -162,7 +162,7 @@ def do_GET(self):
162162
self.end_headers()
163163
# return the token
164164
self.wfile.write(token.to_string())
165-
except oauth.OAuthError, err:
165+
except oauth.OAuthError as err:
166166
self.send_oauth_error(err)
167167
return
168168

@@ -176,7 +176,7 @@ def do_GET(self):
176176
self.end_headers()
177177
# return the extra parameters - just for something to return
178178
self.wfile.write(str(params))
179-
except oauth.OAuthError, err:
179+
except oauth.OAuthError as err:
180180
self.send_oauth_error(err)
181181
return
182182

oauth2/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def to_unicode(s):
102102
raise TypeError('You are required to pass either unicode or string here, not: %r (%s)' % (type(s), s))
103103
try:
104104
s = s.decode('utf-8')
105-
except UnicodeDecodeError, le:
105+
except UnicodeDecodeError as le:
106106
raise TypeError('You are required to pass either a unicode object or a utf-8 string here. You passed a Python string object which contained non-utf-8: %r. The UnicodeDecodeError that resulted from attempting to interpret it as utf-8 was: %s' % (s, le,))
107107
return s
108108

@@ -131,7 +131,7 @@ def to_unicode_optional_iterator(x):
131131

132132
try:
133133
l = list(x)
134-
except TypeError, e:
134+
except TypeError as e:
135135
assert 'is not iterable' in str(e)
136136
return x
137137
else:
@@ -147,7 +147,7 @@ def to_utf8_optional_iterator(x):
147147

148148
try:
149149
l = list(x)
150-
except TypeError, e:
150+
except TypeError as e:
151151
assert 'is not iterable' in str(e)
152152
return x
153153
else:
@@ -460,7 +460,7 @@ def get_normalized_parameters(self):
460460
else:
461461
try:
462462
value = list(value)
463-
except TypeError, e:
463+
except TypeError as e:
464464
assert 'is not iterable' in str(e)
465465
items.append((to_utf8_if_string(key), to_utf8_if_string(value)))
466466
else:

tests/test_oauth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ class TestError(unittest.TestCase):
4949
def test_message(self):
5050
try:
5151
raise oauth.Error
52-
except oauth.Error, e:
52+
except oauth.Error as e:
5353
self.assertEqual(e.message, 'OAuth error occurred.')
5454

5555
msg = 'OMG THINGS BROKE!!!!'
5656
try:
5757
raise oauth.Error(msg)
58-
except oauth.Error, e:
58+
except oauth.Error as e:
5959
self.assertEqual(e.message, msg)
6060

6161
def test_str(self):
6262
try:
6363
raise oauth.Error
64-
except oauth.Error, e:
64+
except oauth.Error as e:
6565
self.assertEquals(str(e), 'OAuth error occurred.')
6666

6767
class TestGenerateFunctions(unittest.TestCase):

0 commit comments

Comments
 (0)