2to3 -f except
diff --git a/googleapiclient/discovery.py b/googleapiclient/discovery.py
index 51d2773..03a3ea7 100644
--- a/googleapiclient/discovery.py
+++ b/googleapiclient/discovery.py
@@ -205,7 +205,7 @@
try:
service = json.loads(content)
- except ValueError, e:
+ except ValueError as e:
logger.error('Failed to parse as JSON: ' + content)
raise InvalidJsonError()
diff --git a/googleapiclient/http.py b/googleapiclient/http.py
index 3959d81..d54ce5e 100644
--- a/googleapiclient/http.py
+++ b/googleapiclient/http.py
@@ -1328,7 +1328,7 @@
if resp.status >= 300:
raise HttpError(resp, content, uri=request.uri)
response = request.postproc(resp, content)
- except HttpError, e:
+ except HttpError as e:
exception = e
if callback is not None:
diff --git a/samples/analytics/core_reporting_v3_reference.py b/samples/analytics/core_reporting_v3_reference.py
index 566cf2d..effb5d9 100755
--- a/samples/analytics/core_reporting_v3_reference.py
+++ b/samples/analytics/core_reporting_v3_reference.py
@@ -84,11 +84,11 @@
results = get_api_query(service, flags.table_id).execute()
print_results(results)
- except TypeError, error:
+ except TypeError as error:
# Handle errors in constructing a query.
print ('There was an error in constructing your query : %s' % error)
- except HttpError, error:
+ except HttpError as error:
# Handle API errors.
print ('Arg, there was an API error : %s : %s' %
(error.resp.status, error._get_reason()))
diff --git a/samples/analytics/hello_analytics_api_v3.py b/samples/analytics/hello_analytics_api_v3.py
index 686197b..e0514db 100755
--- a/samples/analytics/hello_analytics_api_v3.py
+++ b/samples/analytics/hello_analytics_api_v3.py
@@ -66,11 +66,11 @@
results = get_top_keywords(service, first_profile_id)
print_results(results)
- except TypeError, error:
+ except TypeError as error:
# Handle errors in constructing a query.
print ('There was an error in constructing your query : %s' % error)
- except HttpError, error:
+ except HttpError as error:
# Handle API errors.
print ('Arg, there was an API error : %s : %s' %
(error.resp.status, error._get_reason()))
diff --git a/samples/analytics/management_v3_reference.py b/samples/analytics/management_v3_reference.py
index 5fdbd93..4151d7e 100755
--- a/samples/analytics/management_v3_reference.py
+++ b/samples/analytics/management_v3_reference.py
@@ -71,11 +71,11 @@
try:
traverse_hiearchy(service)
- except TypeError, error:
+ except TypeError as error:
# Handle errors in constructing a query.
print ('There was an error in constructing your query : %s' % error)
- except HttpError, error:
+ except HttpError as error:
# Handle API errors.
print ('Arg, there was an API error : %s : %s' %
(error.resp.status, error._get_reason()))
diff --git a/samples/coordinate/coordinate.py b/samples/coordinate/coordinate.py
index a9c3b96..00a1f62 100644
--- a/samples/coordinate/coordinate.py
+++ b/samples/coordinate/coordinate.py
@@ -91,7 +91,7 @@
pprint.pprint(update_result)
- except AccessTokenRefreshError, e:
+ except AccessTokenRefreshError as e:
print ('The credentials have been revoked or expired, please re-run'
'the application to re-authorize')
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index a2593e2..032975c 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -368,7 +368,7 @@
zoo = build('zoo', 'v1', http=http, developerKey='foo',
discoveryServiceUrl='http://example.com')
self.fail('Should have raised an exception.')
- except HttpError, e:
+ except HttpError as e:
self.assertEqual(e.uri, 'http://example.com?userIp=10.0.0.1')
def test_userip_missing_is_not_added_to_discovery_uri(self):
@@ -381,7 +381,7 @@
zoo = build('zoo', 'v1', http=http, developerKey=None,
discoveryServiceUrl='http://example.com')
self.fail('Should have raised an exception.')
- except HttpError, e:
+ except HttpError as e:
self.assertEqual(e.uri, 'http://example.com')
@@ -395,28 +395,28 @@
try:
plus.activities().list()
self.fail()
- except TypeError, e:
+ except TypeError as e:
self.assertTrue('Missing' in str(e))
# Missing required parameters even if supplied as None.
try:
plus.activities().list(collection=None, userId=None)
self.fail()
- except TypeError, e:
+ except TypeError as e:
self.assertTrue('Missing' in str(e))
# Parameter doesn't match regex
try:
plus.activities().list(collection='not_a_collection_name', userId='me')
self.fail()
- except TypeError, e:
+ except TypeError as e:
self.assertTrue('not an allowed value' in str(e))
# Unexpected parameter
try:
plus.activities().list(flubber=12)
self.fail()
- except TypeError, e:
+ except TypeError as e:
self.assertTrue('unexpected' in str(e))
def _check_query_types(self, request):
@@ -785,7 +785,7 @@
try:
request.execute(http=http)
self.fail('Should have raised ResumableUploadError.')
- except ResumableUploadError, e:
+ except ResumableUploadError as e:
self.assertEqual(400, e.resp.status)
def test_resumable_media_fail_unknown_response_code_subsequent_request(self):
@@ -885,7 +885,7 @@
try:
body = request.execute(http=http)
- except HttpError, e:
+ except HttpError as e:
self.assertEqual('01234', e.content)
except ImportError:
@@ -1040,7 +1040,7 @@
try:
# Should resume the upload by first querying the status of the upload.
request.next_chunk(http=http)
- except HttpError, e:
+ except HttpError as e:
expected = {
'Content-Range': 'bytes */14',
'content-length': '0'
diff --git a/tests/test_http.py b/tests/test_http.py
index b4bf007..63ccf1e 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -796,7 +796,7 @@
try:
batch.execute(http=http)
self.fail('Should raise exception')
- except BatchError, e:
+ except BatchError as e:
boundary, _ = e.content.split(None, 1)
self.assertEqual('--', boundary[:2])
parts = e.content.split(boundary)
diff --git a/tests/test_json_model.py b/tests/test_json_model.py
index fccd549..d4f84d5 100644
--- a/tests/test_json_model.py
+++ b/tests/test_json_model.py
@@ -152,7 +152,7 @@
try:
content = model.response(resp, content)
self.fail('Should have thrown an exception')
- except HttpError, e:
+ except HttpError as e:
self.assertTrue('not authorized' in str(e))
resp['content-type'] = 'application/json'
@@ -160,7 +160,7 @@
try:
content = model.response(resp, content)
self.fail('Should have thrown an exception')
- except HttpError, e:
+ except HttpError as e:
self.assertTrue('not authorized' in str(e))
def test_good_response(self):
diff --git a/tests/test_mocks.py b/tests/test_mocks.py
index 7d1e8e6..60cc108 100644
--- a/tests/test_mocks.py
+++ b/tests/test_mocks.py
@@ -140,7 +140,7 @@
try:
activity = plus.activities().list(collection='public', userId='me').execute()
self.fail('An exception should have been thrown')
- except HttpError, e:
+ except HttpError as e:
self.assertEqual('{}', e.content)
self.assertEqual(500, e.resp.status)
self.assertEqual('Server Error', e.resp.reason)