From 4505629ca8937174cfdd610065e6c944aa058cb4 Mon Sep 17 00:00:00 2001 From: TrueTechy Date: Sun, 29 Sep 2019 23:34:39 +0100 Subject: [PATCH] Add explicit file encoding to file handlers --- resources/lib/database/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/lib/database/__init__.py b/resources/lib/database/__init__.py index 69367b72..f3bbc872 100644 --- a/resources/lib/database/__init__.py +++ b/resources/lib/database/__init__.py @@ -333,7 +333,7 @@ def get_sync(): xbmcvfs.mkdirs(path) try: - with open(os.path.join(path, 'sync.json')) as infile: + with open(os.path.join(path, 'sync.json'), encoding='utf-8') as infile: sync = json.load(infile) except Exception: sync = {} @@ -354,7 +354,7 @@ def save_sync(sync): sync['Date'] = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') - with open(os.path.join(path, 'sync.json'), 'w') as outfile: + with open(os.path.join(path, 'sync.json'), 'w', encoding='utf-8') as outfile: data = json.dumps(sync, sort_keys=True, indent=4, ensure_ascii=False) outfile.write(unicode(data)) @@ -371,7 +371,7 @@ def get_credentials(): except Exception: try: - with open(os.path.join(path, 'data.txt')) as infile: + with open(os.path.join(path, 'data.txt'), encoding='utf-8') as infile: credentials = json.load(infile) save_credentials(credentials)