From cc3e5fd7c653da8d0b00d903b4041b7d92d368f2 Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Wed, 15 Jul 2020 14:25:04 -0600 Subject: [PATCH] explorer: use binary mode for opening files --- capa/ida/ida_capa_explorer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/capa/ida/ida_capa_explorer.py b/capa/ida/ida_capa_explorer.py index c1b22cd8..c3a63390 100644 --- a/capa/ida/ida_capa_explorer.py +++ b/capa/ida/ida_capa_explorer.py @@ -271,8 +271,8 @@ class CapaExplorerForm(idaapi.PluginForm): path = idaapi.ask_file(True, "*.json", "Choose file") if os.path.exists(path) and 1 != idaapi.ask_yn(1, "File already exists. Overwrite?"): return - with open(path, "w") as export_file: - json.dump(self.doc, export_file, sort_keys=True, cls=capa.render.CapaJsonObjectEncoder) + with open(path, "wb") as export_file: + export_file.write(json.dumps(self.doc, sort_keys=True, cls=capa.render.CapaJsonObjectEncoder).encode('utf-8')) def load_ida_hooks(self): """ load IDA Pro UI hooks """