aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/state.py
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/state.py')
-rw-r--r--nikola/state.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/nikola/state.py b/nikola/state.py
index 6632e4f..4669d13 100644
--- a/nikola/state.py
+++ b/nikola/state.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2016 Roberto Alsina and others.
+# Copyright © 2012-2020 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -81,12 +81,7 @@ class Persistor():
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
+ with tempfile.NamedTemporaryFile(dir=dname, delete=False, mode='w+', encoding='utf-8') as outf:
tname = outf.name
- data = json.dumps(self._local.data, sort_keys=True, indent=2)
- try:
- outf.write(data)
- except TypeError:
- outf.write(data.encode('utf-8'))
+ json.dump(self._local.data, outf, sort_keys=True, indent=2)
shutil.move(tname, self._path)