From 9ebf2983fe444770f180a110278e45071477b094 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 20 Jun 2019 14:15:02 +0200 Subject: [PATCH] Cast Paths to string: pathlib for older pythons doesn't properly work --- pyrogram/client/client.py | 2 +- pyrogram/client/storage/file_storage.py | 4 ++-- pyrogram/client/storage/memory_storage.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 2d18d178..e1bebeaf 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -990,7 +990,7 @@ class Client(Methods, BaseClient): def load_config(self): parser = ConfigParser() - parser.read(self.config_file) + parser.read(str(self.config_file)) if self.api_id and self.api_hash: pass diff --git a/pyrogram/client/storage/file_storage.py b/pyrogram/client/storage/file_storage.py index f52a03a9..e6ba8420 100644 --- a/pyrogram/client/storage/file_storage.py +++ b/pyrogram/client/storage/file_storage.py @@ -77,7 +77,7 @@ class FileStorage(MemoryStorage): if file_exists: try: - with open(path, encoding="utf-8") as f: + with open(str(path), encoding="utf-8") as f: session_json = json.load(f) except ValueError: pass @@ -98,7 +98,7 @@ class FileStorage(MemoryStorage): log.warning('Old session file detected: "{}.OLD". You can remove this file now'.format(path.name)) self.conn = sqlite3.connect( - path, + str(path), timeout=1, check_same_thread=False ) diff --git a/pyrogram/client/storage/memory_storage.py b/pyrogram/client/storage/memory_storage.py index 7eb3a7d0..bf000f35 100644 --- a/pyrogram/client/storage/memory_storage.py +++ b/pyrogram/client/storage/memory_storage.py @@ -46,7 +46,7 @@ class MemoryStorage(Storage): def create(self): with self.lock, self.conn: - with open(Path(__file__).parent / "schema.sql", "r") as schema: + with open(str(Path(__file__).parent / "schema.sql"), "r") as schema: self.conn.executescript(schema.read()) self.conn.execute(