windows fails to open utf-8 files as utf-8
This commit is contained in:
parent
b4b66f9bd5
commit
41d90e1736
2 changed files with 5 additions and 4 deletions
|
@ -36,14 +36,14 @@ def add_record(action, *args, **kwargs):
|
||||||
revision = next_revision()
|
revision = next_revision()
|
||||||
|
|
||||||
data = [revision, timestamp, [action] + list(args)]
|
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()
|
path = changelog_path()
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
mode = 'a'
|
mode = 'ab'
|
||||||
state.changelog_size = os.path.getsize(path)
|
state.changelog_size = os.path.getsize(path)
|
||||||
else:
|
else:
|
||||||
mode = 'w'
|
mode = 'wb'
|
||||||
state.changelog_size = 0
|
state.changelog_size = 0
|
||||||
makefolder(path)
|
makefolder(path)
|
||||||
with open(path, mode) as fd:
|
with open(path, mode) as fd:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import codecs
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -52,7 +53,7 @@ class Peer(object):
|
||||||
def apply_log(self):
|
def apply_log(self):
|
||||||
changes = []
|
changes = []
|
||||||
if os.path.exists(self._logpath):
|
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:
|
for line in fd:
|
||||||
if line:
|
if line:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue