Skip to content

Commit

Permalink
Fix #2237 -- make state saving work on py3
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Feb 8, 2016
1 parent 68d0a1e commit 9069eba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nikola/state.py
Expand Up @@ -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.