Skip to content
Permalink
Browse files
Fix #2237 -- make state saving work on py3
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Feb 8, 2016
1 parent 68d0a1e commit 9069eba8a696d9411743ea01228f428f8622e2b3
Showing with 6 additions and 1 deletion.
  1. +6 −1 nikola/state.py
@@ -78,6 +78,11 @@ def _read(self):
def _save(self):
dname = os.path.dirname(self._path)
with tempfile.NamedTemporaryFile(dir=dname, delete=False) as outf:
# TODO replace with encoding='utf-8' and mode 'w+' in v8
tname = outf.name
json.dump(self._local.data, outf, sort_keys=True, indent=2)
data = json.dumps(self._local.data, sort_keys=True, indent=2)
try:
outf.write(data)
except TypeError:
outf.write(data.encode('utf-8'))
shutil.move(tname, self._path)

0 comments on commit 9069eba

Please sign in to comment.