From b4b02a48933c78ea3e08371b25f39e5768ecda1e Mon Sep 17 00:00:00 2001 From: gryf Date: Wed, 17 Jun 2020 17:40:20 +0200 Subject: [PATCH] Fix for the missing open file mode. --- ebook_converter/utils/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ebook_converter/utils/config.py b/ebook_converter/utils/config.py index 911527c..2c9f528 100644 --- a/ebook_converter/utils/config.py +++ b/ebook_converter/utils/config.py @@ -392,11 +392,13 @@ class XMLConfig(dict): dpath = os.path.dirname(self.file_path) if not os.path.exists(dpath): os.makedirs(dpath, mode=constants_old.CONFIG_DIR_MODE) - with open(self.file_path) as f: + with open(self.file_path, 'w') as f: raw = self.to_raw() f.seek(0) f.truncate() - f.write(raw) + # TODO(gryf): get rid of another proxy for json module which + # stubbornly insist on using bytes instead of unicode objects + f.write(raw.decode('utf-8')) def __enter__(self): self.no_commit = True