From 9df15634928aaccdbe032fb7ee179704ac07f007 Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Thu, 1 Oct 2020 22:41:57 -0600 Subject: [PATCH] Use open instead of file() to export keys to file. Fixes export of Kindle keys in calibre 5.0.1 here. --- DeDRM_plugin/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DeDRM_plugin/config.py b/DeDRM_plugin/config.py index 93f69ae..ad6e82e 100644 --- a/DeDRM_plugin/config.py +++ b/DeDRM_plugin/config.py @@ -431,15 +431,15 @@ class ManageKeysDialog(QDialog): defaultname = "{0}.{1}".format(keyname, self.keyfile_ext) filename = choose_save_file(self, unique_dlg_name, caption, filters, all_files=False, initial_filename=defaultname) if filename: - with file(filename, 'wb') as fname: + with open(filename, 'wb') as fname: if self.binary_file: fname.write(self.plugin_keys[keyname].decode('hex')) elif self.json_file: - fname.write(json.dumps(self.plugin_keys[keyname])) + fname.write(json.dumps(self.plugin_keys[keyname]).encode()) elif self.android_file: for key in self.plugin_keys[keyname]: - fname.write(key) - fname.write("\n") + fname.write(key.encode()) + fname.write(b"\n") else: fname.write(self.plugin_keys[keyname])