Allow no custom __init__() on CustomMarking

stix2.0
Emmanuelle Vargas-Gonzalez 2017-11-15 12:55:34 -05:00
parent ef3ce9f6f0
commit fbce8f15fe
1 changed files with 8 additions and 1 deletions

View File

@ -145,7 +145,14 @@ def CustomMarking(type='x-custom-marking', properties=None):
def __init__(self, **kwargs):
_STIXBase.__init__(self, **kwargs)
cls.__init__(self, **kwargs)
try:
cls.__init__(self, **kwargs)
except (AttributeError, TypeError) as e:
# Don't accidentally catch errors raised in a custom __init__()
if ("has no attribute '__init__'" in str(e) or
str(e) == "object.__init__() takes no parameters"):
return
raise e
_register_marking(_Custom)
return _Custom