Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3280 from NotAFile/py3-more-misc
Browse files Browse the repository at this point in the history
More Misc. py3 fixes
  • Loading branch information
hawkowl authored May 24, 2018
2 parents 7ea07c7 + 17a70cf commit 5b788ab
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from signedjson.sign import verify_signed_json
import six
from six.moves import http_client
from six import iteritems
from twisted.internet import defer
from unpaddedbase64 import decode_base64

Expand Down Expand Up @@ -1388,7 +1389,7 @@ def get_state_for_pdu(self, room_id, event_id):
)

if state_groups:
_, state = state_groups.items().pop()
_, state = list(iteritems(state_groups)).pop()
results = {
(e.type, e.state_key): e for e in state
}
Expand Down Expand Up @@ -2034,7 +2035,7 @@ def _update_context_for_auth_events(self, event, context, auth_events,
this will not be included in the current_state in the context.
"""
state_updates = {
k: a.event_id for k, a in auth_events.iteritems()
k: a.event_id for k, a in iteritems(auth_events)
if k != event_key
}
context.current_state_ids = dict(context.current_state_ids)
Expand All @@ -2044,7 +2045,7 @@ def _update_context_for_auth_events(self, event, context, auth_events,
context.delta_ids.update(state_updates)
context.prev_state_ids = dict(context.prev_state_ids)
context.prev_state_ids.update({
k: a.event_id for k, a in auth_events.iteritems()
k: a.event_id for k, a in iteritems(auth_events)
})
context.state_group = yield self.store.store_state_group(
event.event_id,
Expand Down Expand Up @@ -2096,7 +2097,7 @@ def sort_fun(ev):

def get_next(it, opt=None):
try:
return it.next()
return next(it)
except Exception:
return opt

Expand Down
9 changes: 5 additions & 4 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from canonicaljson import encode_canonical_json
import six
from six import string_types, itervalues, iteritems
from twisted.internet import defer, reactor
from twisted.internet.defer import succeed
from twisted.python.failure import Failure
Expand Down Expand Up @@ -402,7 +403,7 @@ def get_joined_members(self, requester, room_id):
"avatar_url": profile.avatar_url,
"display_name": profile.display_name,
}
for user_id, profile in users_with_profile.iteritems()
for user_id, profile in iteritems(users_with_profile)
})


Expand Down Expand Up @@ -667,7 +668,7 @@ def create_and_send_nonmember_event(

spam_error = self.spam_checker.check_event_for_spam(event)
if spam_error:
if not isinstance(spam_error, basestring):
if not isinstance(spam_error, string_types):
spam_error = "Spam is not permitted here"
raise SynapseError(
403, spam_error, Codes.FORBIDDEN
Expand Down Expand Up @@ -881,7 +882,7 @@ def is_inviter_member_event(e):

state_to_include_ids = [
e_id
for k, e_id in context.current_state_ids.iteritems()
for k, e_id in iteritems(context.current_state_ids)
if k[0] in self.hs.config.room_invite_state_types
or k == (EventTypes.Member, event.sender)
]
Expand All @@ -895,7 +896,7 @@ def is_inviter_member_event(e):
"content": e.content,
"sender": e.sender,
}
for e in state_to_include.itervalues()
for e in itervalues(state_to_include)
]

invitee = UserID.from_string(event.state_key)
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/events_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _enqueue_events(self, events, check_redacted=True, allow_rejected=False):
def _fetch_event_rows(self, txn, events):
rows = []
N = 200
for i in range(1 + len(events) / N):
for i in range(1 + len(events) // N):
evs = events[i * N:(i + 1) * N]
if not evs:
break
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_user_filter(self, user_localpart, filter_id):
desc="get_user_filter",
)

defer.returnValue(json.loads(str(def_json).decode("utf-8")))
defer.returnValue(json.loads(bytes(def_json).decode("utf-8")))

def add_user_filter(self, user_localpart, user_filter):
def_json = encode_canonical_json(user_filter)
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _get_server_verify_key(self, server_name, key_id):

if verify_key_bytes:
defer.returnValue(decode_verify_key_bytes(
key_id, str(verify_key_bytes)
key_id, bytes(verify_key_bytes)
))

@defer.inlineCallbacks
Expand Down

0 comments on commit 5b788ab

Please sign in to comment.