aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/state.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-02-03 19:17:50 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-02-03 19:17:50 -0500
commit475d074fd74425efbe783fad08f97f2df0c4909f (patch)
tree2acdae53999b3c74b716efa4edb5b40311fa356a /nikola/state.py
parentcd502d52787f666fff3254d7d7e7578930c813c2 (diff)
parent3a0d66f07b112b6d2bdc2b57bbf717a89a351ce6 (diff)
Update upstream source from tag 'upstream/8.1.2'
Update to upstream version '8.1.2' with Debian dir e5e966a9e6010ef70618dc9a61558fa4db35aceb
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)