mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-04 08:15:08 +00:00
Force UTF-8 encoding when r/w'ing text files
This commit is contained in:
@@ -42,7 +42,7 @@ class Error(Exception):
|
||||
|
||||
# TODO: Proper log unknown errors
|
||||
if self.CODE == 520:
|
||||
with open("unknown_errors.txt", "a") as f:
|
||||
with open("unknown_errors.txt", "a", encoding="utf-8") as f:
|
||||
f.write("{}\t{}\t{}\n".format(x.error_code, x.error_message, query_type))
|
||||
|
||||
@staticmethod
|
||||
|
@@ -311,7 +311,7 @@ class Client:
|
||||
|
||||
def load_session(self, session_name):
|
||||
try:
|
||||
with open("{}.session".format(session_name)) as f:
|
||||
with open("{}.session".format(session_name), encoding="utf-8") as f:
|
||||
s = json.load(f)
|
||||
except FileNotFoundError:
|
||||
self.dc_id = 1
|
||||
@@ -326,7 +326,7 @@ class Client:
|
||||
auth_key = base64.b64encode(self.auth_key).decode()
|
||||
auth_key = [auth_key[i: i + 43] for i in range(0, len(auth_key), 43)]
|
||||
|
||||
with open("{}.session".format(self.session_name), "w") as f:
|
||||
with open("{}.session".format(self.session_name), "w", encoding="utf-8") as f:
|
||||
json.dump(
|
||||
dict(
|
||||
dc_id=self.dc_id,
|
||||
|
Reference in New Issue
Block a user