Merge pull request #15 from fukusuket/hotfix/unicode-decode-error-on-windows

Fix UnicodeDecodeError on Windows.
pull/16/head
Alexandre Dulaunoy 2022-01-03 09:41:44 +01:00 committed by GitHub
commit 3af59f5ecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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).')

View File

@ -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():