NodeMixin - TypeError: multiple bases have instance lay-out conflictSee original GitHub issue
Works: 2.4.3 Breaks: 2.6.0
>>> from munch import Munch >>> from anytree import NodeMixin >>> class MyClass(Munch, NodeMixin): ... pass ... Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: multiple bases have instance lay-out conflict
Where munch is https://github.com/Infinidat/munch
Googling around a bit this seems to be about conflicts in C implementations of classes on
__foo__ attributes. So I did this:
>>> [k for k in dir(Munch) if k in dir(NodeMixin)] ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
but it didn’t make me feel much smarter.
Does this mean anything to you anytree peeps? I came here because obviously NodeMixin is meant to be mixed in so this feels like a bug rather than just a stupid thing I should not be attempting to do. Especially as it used to work until this version.
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
slots will be removed
__slots__ has been added. Please try:
>>> from munch import Munch >>> from anytree import NodeMixin >>> class MyNodeMixin(NodeMixin): ... pass >>> class MyClass(Munch, MyNodeMixin): ... pass
__slots__ is not inherited, it might work