mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
Apply Python 3 futurize transform lib2to3.fixes.fix_except.
This commit is contained in:
@@ -71,7 +71,7 @@ class Command(BaseCommand):
|
||||
if options['realms']:
|
||||
try:
|
||||
realms = [get_realm(domain) for domain in options['realms']]
|
||||
except Realm.DoesNotExist, e:
|
||||
except Realm.DoesNotExist as e:
|
||||
print e
|
||||
exit(1)
|
||||
else:
|
||||
|
||||
@@ -15,7 +15,7 @@ class Command(BaseCommand):
|
||||
if options['realms']:
|
||||
try:
|
||||
realms = [get_realm(domain) for domain in options['realms']]
|
||||
except Realm.DoesNotExist, e:
|
||||
except Realm.DoesNotExist as e:
|
||||
print e
|
||||
exit(1)
|
||||
else:
|
||||
|
||||
@@ -22,7 +22,7 @@ class Command(BaseCommand):
|
||||
if options['realms']:
|
||||
try:
|
||||
realms = [get_realm(domain) for domain in options['realms']]
|
||||
except Realm.DoesNotExist, e:
|
||||
except Realm.DoesNotExist as e:
|
||||
print e
|
||||
exit(1)
|
||||
else:
|
||||
|
||||
@@ -242,7 +242,7 @@ def authenticated_rest_api_view(view_func):
|
||||
try:
|
||||
# Could be a UserProfile or a Deployment
|
||||
profile = validate_api_key(role, api_key)
|
||||
except JsonableError, e:
|
||||
except JsonableError as e:
|
||||
return json_unauthorized(e.error)
|
||||
request.user = profile
|
||||
process_client(request, profile)
|
||||
|
||||
@@ -34,7 +34,7 @@ def not_mit_mailing_list(value):
|
||||
try:
|
||||
DNS.dnslookup("%s.pobox.ns.athena.mit.edu" % username, DNS.Type.TXT)
|
||||
return True
|
||||
except DNS.Base.ServerError, e:
|
||||
except DNS.Base.ServerError as e:
|
||||
if e.rcode == DNS.Status.NXDOMAIN:
|
||||
raise ValidationError(mark_safe(u'That user does not exist at MIT or is a <a href="https://ist.mit.edu/email-lists">mailing list</a>. If you want to sign up an alias for Zulip, <a href="mailto:support@zulip.com">contact us</a>.'))
|
||||
else:
|
||||
|
||||
@@ -890,7 +890,7 @@ def check_message(sender, client, message_type_name, message_to,
|
||||
try:
|
||||
recipient = recipient_for_emails(message_to, not_forged_mirror_message,
|
||||
forwarder_user_profile, sender)
|
||||
except ValidationError, e:
|
||||
except ValidationError as e:
|
||||
assert isinstance(e.messages[0], basestring)
|
||||
raise JsonableError(e.messages[0])
|
||||
else:
|
||||
@@ -940,7 +940,7 @@ def internal_prep_message(sender_email, recipient_type_name, recipients,
|
||||
try:
|
||||
return check_message(sender, get_client("Internal"), recipient_type_name,
|
||||
parsed_recipients, subject, content, realm)
|
||||
except JsonableError, e:
|
||||
except JsonableError as e:
|
||||
logging.error("Error queueing internal message by %s: %s" % (sender_email, str(e)))
|
||||
|
||||
return None
|
||||
|
||||
@@ -278,6 +278,6 @@ def process_message(message, rcpt_to=None, pre_checked=False):
|
||||
process_missed_message(to, message, pre_checked)
|
||||
else:
|
||||
process_stream_message(to, subject, message, debug_info)
|
||||
except ZulipEmailForwardError, e:
|
||||
except ZulipEmailForwardError as e:
|
||||
# TODO: notify sender of error, retry if appropriate.
|
||||
log_and_report(message, e.message, debug_info)
|
||||
|
||||
@@ -22,7 +22,7 @@ def run_parallel(job, data, threads=6):
|
||||
sys.stdin.close()
|
||||
try:
|
||||
os.close(pty.STDIN_FILENO)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.EBADF:
|
||||
raise
|
||||
sys.stdin = open("/dev/null", "r")
|
||||
@@ -43,7 +43,7 @@ def run_parallel(job, data, threads=6):
|
||||
try:
|
||||
(status, item) = wait_for_one()
|
||||
yield (status, item)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno == errno.ECHILD:
|
||||
break
|
||||
else:
|
||||
|
||||
@@ -99,7 +99,7 @@ class SimpleQueueClient(object):
|
||||
try:
|
||||
consumer(ch, method, properties, body)
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
ch.basic_nack(delivery_tag=method.delivery_tag)
|
||||
raise e
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
||||
if response is RespondAsynchronously:
|
||||
async_request_stop(request)
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# If the view raised an exception, run it through exception
|
||||
# middleware, and if the exception middleware returns a
|
||||
# response, use that. Otherwise, reraise the exception.
|
||||
@@ -265,7 +265,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
||||
response = response.render()
|
||||
|
||||
|
||||
except http.Http404, e:
|
||||
except http.Http404 as e:
|
||||
if settings.DEBUG:
|
||||
from django.views import debug
|
||||
response = debug.technical_404_response(request, e)
|
||||
@@ -298,7 +298,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
||||
except SystemExit:
|
||||
# See https://code.djangoproject.com/ticket/4701
|
||||
raise
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
exc_info = sys.exc_info()
|
||||
signals.got_request_exception.send(sender=self.__class__, request=request)
|
||||
return self.handle_uncaught_exception(request, resolver, exc_info)
|
||||
|
||||
@@ -94,7 +94,7 @@ class TestStreamEmailMessagesEmptyBody(AuthedTestCase):
|
||||
incoming_valid_message['Subject'],
|
||||
incoming_valid_message,
|
||||
debug_info)
|
||||
except ZulipEmailForwardError, e:
|
||||
except ZulipEmailForwardError as e:
|
||||
# empty body throws exception
|
||||
exception_message = e.message
|
||||
self.assertEqual(exception_message, "Unable to find plaintext or HTML message body")
|
||||
|
||||
@@ -719,7 +719,7 @@ def api_stash_webhook(request, user_profile, stream=REQ(default='')):
|
||||
entry["toCommit"]["message"].split("\n")[0]) for \
|
||||
entry in commit_entries]
|
||||
head_ref = commit_entries[-1]["toCommit"]["displayId"]
|
||||
except KeyError, e:
|
||||
except KeyError as e:
|
||||
return json_error("Missing key %s in JSON" % (e.message,))
|
||||
|
||||
try:
|
||||
|
||||
@@ -104,7 +104,7 @@ class SignupWorker(QueueProcessingWorker):
|
||||
merge_vars=merge_vars,
|
||||
double_optin=False,
|
||||
send_welcome=False)
|
||||
except MailChimpException, e:
|
||||
except MailChimpException as e:
|
||||
if e.code == 214:
|
||||
logging.warning("Attempted to sign up already existing email to list: %s" % (data['EMAIL'],))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user