use explicit utf-8 encoding when opening files in text mode
This commit is contained in:
@@ -66,7 +66,7 @@ class ExchangeBase(PrintError):
|
||||
if os.path.exists(filename):
|
||||
timestamp = os.stat(filename).st_mtime
|
||||
try:
|
||||
with open(filename, 'r') as f:
|
||||
with open(filename, 'r', encoding='utf-8') as f:
|
||||
h = json.loads(f.read())
|
||||
h['timestamp'] = timestamp
|
||||
except:
|
||||
@@ -87,7 +87,7 @@ class ExchangeBase(PrintError):
|
||||
self.print_error("failed fx history:", e)
|
||||
return
|
||||
filename = os.path.join(cache_dir, self.name() + '_' + ccy)
|
||||
with open(filename, 'w') as f:
|
||||
with open(filename, 'w', encoding='utf-8') as f:
|
||||
f.write(json.dumps(h))
|
||||
h['timestamp'] = time.time()
|
||||
self.history[ccy] = h
|
||||
@@ -382,7 +382,7 @@ def get_exchanges_and_currencies():
|
||||
import os, json
|
||||
path = os.path.join(os.path.dirname(__file__), 'currencies.json')
|
||||
try:
|
||||
with open(path, 'r') as f:
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
return json.loads(f.read())
|
||||
except:
|
||||
pass
|
||||
@@ -399,7 +399,7 @@ def get_exchanges_and_currencies():
|
||||
except:
|
||||
print(name, "error")
|
||||
continue
|
||||
with open(path, 'w') as f:
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
f.write(json.dumps(d, indent=4, sort_keys=True))
|
||||
return d
|
||||
|
||||
|
||||
Reference in New Issue
Block a user