diff --git a/fsl/data/mesh.py b/fsl/data/mesh.py index dcf4054e4e7568291d2e1c1ae681e206f8d6805c..bb2d9b2377ad25dec43614387d0383eabf086100 100644 --- a/fsl/data/mesh.py +++ b/fsl/data/mesh.py @@ -144,6 +144,14 @@ class Mesh(notifier.Notifier, meta.Meta): """ + def __new__(cls, *args, **kwargs): + """Create a ``Mesh``. We must override ``__new__``, otherwise the + :class:`Meta` and :class:`Notifier` ``__new__`` methods will not be + called correctly. + """ + return super(Mesh, cls).__new__(cls, *args, **kwargs) + + def __init__(self, indices, name='mesh', diff --git a/fsl/utils/meta.py b/fsl/utils/meta.py index f380fdbf1c4fe45718736bf8a6194e27891fc0d2..3e65d398ec078817242dd5c8ee205db7b7e957e0 100644 --- a/fsl/utils/meta.py +++ b/fsl/utils/meta.py @@ -27,8 +27,13 @@ class Meta(object): setMeta """ - def __init__(self): - self.__meta = collections.OrderedDict() + def __new__(cls, *args, **kwargs): + """Initialises a ``Meta`` instance. """ + + new = super(Meta, cls).__new__(cls) + new.__meta = collections.OrderedDict() + + return new def metaKeys(self): diff --git a/fsl/utils/notifier.py b/fsl/utils/notifier.py index f207a2be2e3c544afc2116e394d45016ab155e6b..cd07204e4907175c8f8a5bf3bfa21ebd7a5d2fd9 100644 --- a/fsl/utils/notifier.py +++ b/fsl/utils/notifier.py @@ -94,7 +94,7 @@ class Notifier(object): instance. """ - new = object.__new__(cls) + new = super(Notifier, cls).__new__(cls) # Listeners are stored in this #