From fbce8f15fe5278c06a79f0cadb6ac624d9fbe8cf Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Wed, 15 Nov 2017 12:55:34 -0500 Subject: [PATCH] Allow no custom __init__() on CustomMarking --- stix2/v20/common.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stix2/v20/common.py b/stix2/v20/common.py index 2d15529..ef45060 100644 --- a/stix2/v20/common.py +++ b/stix2/v20/common.py @@ -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