Fix UnicodeDecodeError on windows.

pull/15/head
Fukusuke Takahashi 2021-09-14 23:31:58 +09:00
parent 9879247c6f
commit 86fb1036da
2 changed files with 2 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class WarningLists(collections.Mapping):
lists = [] lists = []
self.root_dir_warninglists = Path(sys.modules['pymispwarninglists'].__file__).parent / 'data' / 'misp-warninglists' / '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')): 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)) lists.append(json.load(f))
if not lists: if not lists:
raise PyMISPWarningListsError('Unable to load the lists. Do not forget to initialize the submodule (git submodule update --init).') 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): def test_dump_warninglists(self):
warninglists_from_files = {} warninglists_from_files = {}
for warninglist_file in glob(os.path.join(self.warninglists.root_dir_warninglists, '*', 'list.json')): 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) warninglist = json.load(f)
warninglists_from_files[warninglist['name']] = warninglist warninglists_from_files[warninglist['name']] = warninglist
for name, w in self.warninglists.items(): for name, w in self.warninglists.items():