From 5c6389fc47aece6a734b30358ba66e5570570425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Thu, 7 Jun 2018 14:43:38 +0200 Subject: [PATCH] encryption: Fix account loading for python3. --- matrix/encryption.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/matrix/encryption.py b/matrix/encryption.py index 2970041..3733aca 100644 --- a/matrix/encryption.py +++ b/matrix/encryption.py @@ -759,15 +759,31 @@ class Olm(): inbound_group_sessions = defaultdict(dict) try: - account = Account.from_pickle(bytes(account_pickle, "utf-8")) + try: + account_pickle = bytes(account_pickle, "utf-8") + except TypeError: + pass + + account = Account.from_pickle(account_pickle) for db_session in db_sessions: + session_pickle = db_session[2] + try: + session_pickle = bytes(session_pickle, "utf-8") + except TypeError: + pass + sessions[db_session[0]][db_session[1]].append( - Session.from_pickle(bytes(db_session[2], "utf-8"))) + Session.from_pickle(session_pickle)) for db_session in db_inbound_group_sessions: - session = InboundGroupSession.from_pickle( - bytes(db_session[1], "utf-8")) + session_pickle = db_session[1] + try: + session_pickle = bytes(session_pickle, "utf-8") + except TypeError: + pass + + session = InboundGroupSession.from_pickle(session_pickle) inbound_group_sessions[db_session[0]][session.id] = session return cls(user, device_id, session_path, database, account,