From 3c92f6a7913ef9bb76093e4450de8b121ecbdfc1 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 4 Sep 2018 11:28:01 +0200 Subject: [PATCH] Fix sqlite's conn may be None if never used This happened when signing up with the library and getting migrate errors. --- telethon/sessions/sqlite.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/sessions/sqlite.py b/telethon/sessions/sqlite.py index b13a850c..ee68449a 100644 --- a/telethon/sessions/sqlite.py +++ b/telethon/sessions/sqlite.py @@ -231,7 +231,8 @@ class SQLiteSession(MemorySession): """Saves the current session object as session_user_id.session""" # This is a no-op if there are no changes to commit, so there's # no need for us to keep track of an "unsaved changes" variable. - self._conn.commit() + if self._conn is not None: + self._conn.commit() def _cursor(self): """Asserts that the connection is open and returns a cursor"""