diff options
author | Andrej Rode <mail@andrejro.de> | 2018-07-31 01:26:49 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-08-07 15:54:05 +0200 |
commit | b9c8c6c3dad2c864655786c8f6ce22910c82e174 (patch) | |
tree | a294a49434ec61cf738472c49a7d4c61ccdaab35 /grc/core/cache.py | |
parent | 7898d61d01f35b369d8487a5d7540fe437ce6033 (diff) |
grc: make cache dumping compatible across Py2/Py3
Diffstat (limited to 'grc/core/cache.py')
-rw-r--r-- | grc/core/cache.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/grc/core/cache.py b/grc/core/cache.py index f438d58bd9..dd85bf9806 100644 --- a/grc/core/cache.py +++ b/grc/core/cache.py @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -from __future__ import absolute_import, print_function +from __future__ import absolute_import, print_function, unicode_literals from io import open import json @@ -73,8 +73,9 @@ class Cache(object): return logger.info('Saving %d entries to json cache', len(self.cache)) + # Dumping to binary file is only supported for Python3 >= 3.6 with open(self.cache_file, 'w', encoding='utf8') as cache_file: - json.dump(self.cache, cache_file) + cache_file.write(json.dumps(self.cache, ensure_ascii=False)) def prune(self): for filename in (set(self.cache) - self._accessed_items): |