fix: Avoiding issues with some extensions that are not dict but defaultdict

master
chrisr3d 2020-01-08 17:00:18 +01:00
parent 36e4b41b9c
commit cbe109d815
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 3 additions and 3 deletions

View File

@ -26,9 +26,9 @@ ID_REGEX_interoperability = re.compile(r"[0-9a-fA-F]{8}-"
"[0-9a-fA-F]{12}$")
try:
from collections.abc import Mapping
from collections.abc import Mapping, defaultdict
except ImportError:
from collections import Mapping
from collections import Mapping, defaultdict
ERROR_INVALID_ID = (
"not a valid STIX identifier, must match <object-type>--<UUID>: {}"
@ -633,7 +633,7 @@ class ExtensionsProperty(DictionaryProperty):
for key, subvalue in dictified.items():
if key in specific_type_map:
cls = specific_type_map[key]
if type(subvalue) is dict:
if isinstance(subvalue, (dict, defaultdict)):
if self.allow_custom:
subvalue['allow_custom'] = True
dictified[key] = cls(**subvalue)