diff --git a/oml/changelog.py b/oml/changelog.py index 3f89f47..55dc853 100644 --- a/oml/changelog.py +++ b/oml/changelog.py @@ -36,14 +36,14 @@ def add_record(action, *args, **kwargs): revision = next_revision() data = [revision, timestamp, [action] + list(args)] - data = json.dumps(data, ensure_ascii=False) + data = json.dumps(data, ensure_ascii=False).encode('utf-8') path = changelog_path() if os.path.exists(path): - mode = 'a' + mode = 'ab' state.changelog_size = os.path.getsize(path) else: - mode = 'w' + mode = 'wb' state.changelog_size = 0 makefolder(path) with open(path, mode) as fd: diff --git a/oml/library.py b/oml/library.py index 3c17ed0..09cc474 100644 --- a/oml/library.py +++ b/oml/library.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import codecs import json import os import time @@ -52,7 +53,7 @@ class Peer(object): def apply_log(self): changes = [] if os.path.exists(self._logpath): - with open(self._logpath) as fd: + with codecs.open(self._logpath, 'r', encoding='utf-8') as fd: for line in fd: if line: try: