From 6a043b7371b9c470ac36ae57ff8694ef422aa1ad Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 8 Jun 2017 16:45:09 +0200 Subject: [PATCH] Fix Session not being able to save auth_key=None --- telethon/tl/session.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/telethon/tl/session.py b/telethon/tl/session.py index a451b9f1..faed2593 100644 --- a/telethon/tl/session.py +++ b/telethon/tl/session.py @@ -123,7 +123,8 @@ class JsonSession: 'time_offset': self.time_offset, 'server_address': self.server_address, 'auth_key_data': - b64encode(self.auth_key.key).decode('ascii') + b64encode(self.auth_key.key).decode('ascii')\ + if self.auth_key else None }, file) def delete(self): @@ -160,8 +161,9 @@ class JsonSession: # FIXME We need to import the AuthKey here or otherwise # we get cyclic dependencies. from ..crypto import AuthKey - key = b64decode(data['auth_key_data']) - result.auth_key = AuthKey(data=key) + if data['auth_key_data'] is not None: + key = b64decode(data['auth_key_data']) + result.auth_key = AuthKey(data=key) except (json.decoder.JSONDecodeError, UnicodeDecodeError): # TODO Backwards-compatibility code