From 86fb1036da5507ceabaa2e441fbb4a53f62e3aee Mon Sep 17 00:00:00 2001 From: Fukusuke Takahashi Date: Tue, 14 Sep 2021 23:31:58 +0900 Subject: [PATCH] Fix UnicodeDecodeError on windows. --- pymispwarninglists/api.py | 2 +- tests/tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pymispwarninglists/api.py b/pymispwarninglists/api.py index d49d6ac..12d6126 100644 --- a/pymispwarninglists/api.py +++ b/pymispwarninglists/api.py @@ -122,7 +122,7 @@ class WarningLists(collections.Mapping): lists = [] self.root_dir_warninglists = Path(sys.modules['pymispwarninglists'].__file__).parent / 'data' / 'misp-warninglists' / 'lists' for warninglist_file in glob(str(self.root_dir_warninglists / '*' / 'list.json')): - with open(warninglist_file, 'r') as f: + with open(warninglist_file, mode='r', encoding="utf-8") as f: lists.append(json.load(f)) if not lists: raise PyMISPWarningListsError('Unable to load the lists. Do not forget to initialize the submodule (git submodule update --init).') diff --git a/tests/tests.py b/tests/tests.py index 2a6f1f0..383a71d 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -16,7 +16,7 @@ class TestPyMISPWarningLists(unittest.TestCase): def test_dump_warninglists(self): warninglists_from_files = {} for warninglist_file in glob(os.path.join(self.warninglists.root_dir_warninglists, '*', 'list.json')): - with open(warninglist_file, 'r') as f: + with open(warninglist_file, mode='r', encoding="utf-8") as f: warninglist = json.load(f) warninglists_from_files[warninglist['name']] = warninglist for name, w in self.warninglists.items():