From cbe109d815a105e208095897bb672e5d2ebbe3ff Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Wed, 8 Jan 2020 17:00:18 +0100 Subject: [PATCH] fix: Avoiding issues with some extensions that are not dict but defaultdict --- stix2/properties.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stix2/properties.py b/stix2/properties.py index 2983bad..9c3af1d 100644 --- a/stix2/properties.py +++ b/stix2/properties.py @@ -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 --: {}" @@ -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)