From e6502710b64b7bd48b17c3b93434039682456788 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Wed, 13 Jul 2016 20:39:49 +0530 Subject: [PATCH] Change exception.message to str(exception). The 'message' attribute in Exception has been deprecated. It has been removed in python 3. --- zerver/lib/email_mirror.py | 2 +- zerver/lib/handlers.py | 4 ++-- zerver/tests/test_email_mirror.py | 4 +--- zerver/views/webhooks/airbrake.py | 2 +- zerver/views/webhooks/bitbucket2.py | 2 +- zerver/views/webhooks/codeship.py | 2 +- zerver/views/webhooks/crashlytics.py | 2 +- zerver/views/webhooks/semaphore.py | 6 +++--- zerver/views/webhooks/stash.py | 2 +- zerver/views/webhooks/updown.py | 2 +- 10 files changed, 13 insertions(+), 15 deletions(-) diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py index aa1250c229..5c5e8e9822 100644 --- a/zerver/lib/email_mirror.py +++ b/zerver/lib/email_mirror.py @@ -326,4 +326,4 @@ def process_message(message, rcpt_to=None, pre_checked=False): process_stream_message(to, subject, message, debug_info) except ZulipEmailForwardError as e: # TODO: notify sender of error, retry if appropriate. - log_and_report(message, e.message, debug_info) + log_and_report(message, str(e), debug_info) diff --git a/zerver/lib/handlers.py b/zerver/lib/handlers.py index db9dfba026..f2ccfa9ac0 100644 --- a/zerver/lib/handlers.py +++ b/zerver/lib/handlers.py @@ -41,10 +41,10 @@ def finish_handler(handler_id, event_queue_id, contents, apply_markdown): queue_id=event_queue_id), request, apply_markdown=apply_markdown) except IOError as e: - if e.message != 'Stream is closed': + if str(e) != 'Stream is closed': logging.exception(err_msg) except AssertionError as e: - if e.message != 'Request closed': + if str(e) != 'Request closed': logging.exception(err_msg) except Exception: logging.exception(err_msg) diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.py index 5049d7629f..6519f017d6 100644 --- a/zerver/tests/test_email_mirror.py +++ b/zerver/tests/test_email_mirror.py @@ -7,7 +7,6 @@ from zerver.lib.test_helpers import ( AuthedTestCase, most_recent_message, most_recent_usermessage, - skip_py3, ) from zerver.models import ( @@ -67,7 +66,6 @@ class TestStreamEmailMessagesSuccess(AuthedTestCase): self.assertEqual(message.subject, incoming_valid_message['Subject']) class TestStreamEmailMessagesEmptyBody(AuthedTestCase): - @skip_py3 def test_receive_stream_email_messages_empty_body(self): # build dummy messages for stream @@ -101,7 +99,7 @@ class TestStreamEmailMessagesEmptyBody(AuthedTestCase): debug_info) except ZulipEmailForwardError as e: # empty body throws exception - exception_message = e.message + exception_message = str(e) self.assertEqual(exception_message, "Unable to find plaintext or HTML message body") class TestMissedPersonalMessageEmailMessages(AuthedTestCase): diff --git a/zerver/views/webhooks/airbrake.py b/zerver/views/webhooks/airbrake.py index 04fa08f0ba..563b211311 100644 --- a/zerver/views/webhooks/airbrake.py +++ b/zerver/views/webhooks/airbrake.py @@ -22,7 +22,7 @@ def api_airbrake_webhook(request, user_profile, client, payload=REQ(argument_typ subject = get_subject(payload) body = get_body(payload) except KeyError as e: - return json_error(_("Missing key {} in JSON").format(e.message)) + return json_error(_("Missing key {} in JSON").format(str(e))) check_send_message(user_profile, client, 'stream', [stream], subject, body) return json_success() diff --git a/zerver/views/webhooks/bitbucket2.py b/zerver/views/webhooks/bitbucket2.py index 58893a4768..80e3e81d18 100644 --- a/zerver/views/webhooks/bitbucket2.py +++ b/zerver/views/webhooks/bitbucket2.py @@ -46,7 +46,7 @@ def api_bitbucket2_webhook(request, user_profile, client, payload=REQ(argument_t type = get_type(request, payload) body = get_body_based_on_type(type)(payload) except KeyError as e: - return json_error(_("Missing key {} in JSON").format(e.message)) + return json_error(_("Missing key {} in JSON").format(str(e))) check_send_message(user_profile, client, 'stream', [stream], subject, body) return json_success() diff --git a/zerver/views/webhooks/codeship.py b/zerver/views/webhooks/codeship.py index d0fc3a3ebd..7bf1a87e86 100644 --- a/zerver/views/webhooks/codeship.py +++ b/zerver/views/webhooks/codeship.py @@ -34,7 +34,7 @@ def api_codeship_webhook(request, user_profile, client, payload=REQ(argument_typ subject = get_subject_for_http_request(payload) body = get_body_for_http_request(payload) except KeyError as e: - return json_error(_("Missing key {} in JSON").format(e.message)) + return json_error(_("Missing key {} in JSON").format(str(e))) check_send_message(user_profile, client, 'stream', [stream], subject, body) return json_success() diff --git a/zerver/views/webhooks/crashlytics.py b/zerver/views/webhooks/crashlytics.py index be9889e669..ac3b4e1e5d 100644 --- a/zerver/views/webhooks/crashlytics.py +++ b/zerver/views/webhooks/crashlytics.py @@ -34,7 +34,7 @@ def api_crashlytics_webhook(request, user_profile, client, payload=REQ(argument_ url=issue_body['url'] ) except KeyError as e: - return json_error(_("Missing key {} in JSON".format(e.message))) + return json_error(_("Missing key {} in JSON".format(str(e)))) check_send_message(user_profile, client, 'stream', [stream], subject, body) diff --git a/zerver/views/webhooks/semaphore.py b/zerver/views/webhooks/semaphore.py index c6665ad0c1..90c6a5ddfc 100644 --- a/zerver/views/webhooks/semaphore.py +++ b/zerver/views/webhooks/semaphore.py @@ -34,14 +34,14 @@ def api_semaphore_webhook(request, user_profile, client, author_email = payload["commit"]["author_email"] message = payload["commit"]["message"] except KeyError as e: - return json_error(_("Missing key %s in JSON") % (e.message,)) + return json_error(_("Missing key %s in JSON") % (str(e),)) if event == "build": try: build_url = payload["build_url"] build_number = payload["build_number"] except KeyError as e: - return json_error(_("Missing key %s in JSON") % (e.message,)) + return json_error(_("Missing key %s in JSON") % (str(e),)) content = u"[build %s](%s): %s\n" % (build_number, build_url, result) elif event == "deploy": @@ -52,7 +52,7 @@ def api_semaphore_webhook(request, user_profile, client, deploy_number = payload["number"] server_name = payload["server_name"] except KeyError as e: - return json_error(_("Missing key %s in JSON") % (e.message,)) + return json_error(_("Missing key %s in JSON") % (str(e),)) content = u"[deploy %s](%s) of [build %s](%s) on server %s: %s\n" % \ (deploy_number, deploy_url, build_number, build_url, server_name, result) diff --git a/zerver/views/webhooks/stash.py b/zerver/views/webhooks/stash.py index e67ebc6d90..15b9d708cd 100644 --- a/zerver/views/webhooks/stash.py +++ b/zerver/views/webhooks/stash.py @@ -31,7 +31,7 @@ def api_stash_webhook(request, user_profile, payload=REQ(argument_type='body'), entry in commit_entries] head_ref = commit_entries[-1]["toCommit"]["displayId"] except KeyError as e: - return json_error(_("Missing key %s in JSON") % (e.message,)) + return json_error(_("Missing key %s in JSON") % (str(e),)) subject = "%s/%s: %s" % (project_name, repo_name, branch_name) diff --git a/zerver/views/webhooks/updown.py b/zerver/views/webhooks/updown.py index 003aba0452..c3b9678dac 100644 --- a/zerver/views/webhooks/updown.py +++ b/zerver/views/webhooks/updown.py @@ -25,7 +25,7 @@ def send_message_for_event(event, user_profile, client, stream): subject = SUBJECT_TEMPLATE.format(service_url=event['check']['url']) body = EVENT_TYPE_BODY_MAPPER[event_type](event) except KeyError as e: - return json_error(_("Missing key {} in JSON").format(e.message)) + return json_error(_("Missing key {} in JSON").format(str(e))) check_send_message(user_profile, client, 'stream', [stream], subject, body) def get_body_for_up_event(event):